# Document

```javascript
import { Document } from 'slate'
```

The top-level node in Slate's document model.

Documents are made up of block nodes, inline nodes, and text nodes—just like in the DOM. Note that direct descendants of a document node have to be block nodes.

In some places, you'll see mention of "fragments", which are also `Document` objects, just that aren't attached to the main `Value`. For example, when cutting-and-pasting a selection of content, that content will be referred to as a document "fragment".

## Properties

```javascript
Document({
  nodes: Immutable.List<Node>,
})
```

### `data`

`Immutable.Map`

Arbitrary data associated with the document. Defaults to an empty `Map`.

### `object`

`String`

An immutable string value of `'document'` for easily separating this node from [`Block`](/v0.47/slate-core/block.md), [`Inline`](/v0.47/slate-core/inline.md) or [`Text`](/v0.47/slate-core/text.md) nodes.

### `nodes`

`Immutable.List`

A list of child nodes.

## Computed Properties

### `text`

`String`

A concatenated string of all of the descendant [`Text`](/v0.47/slate-core/text.md) nodes of this node.

## Static Methods

### `Document.create`

`Document.create(properties: Object) => Document`

Create a document from a plain JavaScript object of `properties`.

### `Document.fromJSON`

`Document.fromJSON(object: Object) => Document`

Create a document from a JSON `object`.

### `Document.isDocument`

`Document.isDocument(maybeDocument: Any) => Boolean`

Returns a boolean if the passed in argument is a `Document`.

## Node Methods

Documents implement the [`Node`](/v0.47/slate-core/node.md) interface. For information about all of the node methods, see the [`Node` reference](/v0.47/slate-core/node.md).

## Instance Methods

### `toJSON`

`toJSON() => Object`

Returns a JSON representation of the document.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.slatejs.org/v0.47/slate-core/document.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
