> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/cloud/database/schema/field-types/textarea-html.md).

# Long text and HTML

A text field shown as a multi-line box (Long text) or as a code editor for HTML (HTML). Same data rules as Text.

**Long text** and **HTML** are the same string field as [Text](/codemash/cloud/database/schema/field-types/text.md), with a bigger input: a multi-line textarea, or a code editor for markup. The data schema is identical; only the widget differs.

**Builder:** Form fields panel → **Long text / HTML** · widget `textarea` / `html` · data type `string.schema.v1`

## Data schema

```json
{
  "body": {
    "type": "string",
    "maxLength": 20000
  }
}
```

| Keyword                        | Required | What it does                                                       | Example    |
| ------------------------------ | -------- | ------------------------------------------------------------------ | ---------- |
| `type`                         | yes      | Always `"string"`.                                                 | `"string"` |
| `minLength` / `maxLength`      | no       | Length limits in characters, HTML tags included.                   | `20000`    |
| `pattern`, `default`, `unique` | no       | As on [Text](/codemash/cloud/database/schema/field-types/text.md). |            |

### What the server refuses

Every write — insert, update, replace; from Cloud, the API, an SDK, the CLI or an AI agent — is checked against the published schema. A broken value is answered with one error per field: the code, and `Field '<name>' is invalid: <reason>`. Nothing is written.

| Case                                  | Code                     | The reason it gives                |
| ------------------------------------- | ------------------------ | ---------------------------------- |
| a required field is missing or `null` | `CM-ERRORS-DATABASE-030` | `a value is required`              |
| the value is not a string             | `CM-ERRORS-DATABASE-039` | `must be a string`                 |
| longer than `maxLength`               | `CM-ERRORS-DATABASE-040` | `must be at most 20000 characters` |

A keyword that is not in the table above is refused when the schema is **saved**, not when a record is written: `CM-ERRORS-SCHEMA-010` — `Data schema violates meta-schema: Property 'sort' has not been defined and the schema does not allow additional properties. Path 'properties.body.sort' (field 'properties.body' checked as string.schema.v1).`

## UI schema

`textarea` is a plain multi-line box; `html` is a code editor with line numbers. Both store the text exactly as typed — the server does not clean or render HTML.

```json
{
  "colSpan": 12,
  "element": {
    "fieldId": "body",
    "meta": { "widget": "html", "label": "Body" }
  }
}
```

Every cell also takes the common layout options: `label`, `placeholder`, `help` (the text under the input), `required`, `readonly` and `hidden`. Keys outside this list — `watermark`, `hint`, `permissions` — are refused when the schema is saved (`CM-ERRORS-SCHEMA-012`), see [Schema authoring guide](/codemash/cloud/database/schema.md#one-contract-no-second-dialect).

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-ebf915cf71f4945a3c0d5bf9ef1529c892da44f4%2Ffield-types-text-1.png?alt=media" alt="The Text tab of the all-types record form; the last field, String min length, uses the html widget and is shown as a dark code editor with line numbers across the full width"><figcaption><p>An html cell (String min length) rendered as a code editor; a textarea cell is a plain multi-line box.</p></figcaption></figure>

## Records

A record the schema accepts:

```json
{ "body": "<p>Hello</p>" }
```

A record it refuses:

```json
{ "body": ["<p>Hello</p>"] }
```

The answer: `CM-ERRORS-DATABASE-039` — `Field 'body' is invalid: must be a string`. In Cloud the same sentence is shown under the field before the form is sent; the server repeats the check on every API write.

## Good to know

* The records list shows the first characters of a long text; open the record to read it all.
* To keep one text per language, add `meta.translateOptions` — see [Translatable text](/codemash/cloud/database/schema/field-types/translatable.md).

## Do it from code

```ts
await norbix.api.database.insertOne({
  collectionName: 'posts',
  document: JSON.stringify({ body: '<p>Hello</p>' }),
});
```

```sh
norbix api database one insert --collectionName posts --document '{"body":"<p>Hello</p>"}'
```

The client setup is on the [Database page](/codemash/cloud/database.md#use-it-from-code). API: [Insert One](/codemash/api-reference/database/collections/insert-one.md) · [Save Database Schema](/codemash/api-reference/database/schemas/save-database-schema.md)

## Related

[Text](/codemash/cloud/database/schema/field-types/text.md) · [Translatable text](/codemash/cloud/database/schema/field-types/translatable.md) · [Field type reference](/codemash/cloud/database/schema/field-types.md) · [Schema authoring guide](/codemash/cloud/database/schema.md) · [Create a schema](/codemash/cloud/database/collections/create-schema.md)
