Skip to content

Json Editor

Forms

An editor for JSON values built on atlas-code-editor. [(value)] is the parsed value (object, array, string, number, boolean or null); the editor shows it indented, validates every edit and shows the parse error under the box. It uses whatever engine atlas-code-editor uses.

atlas-json-editor

Examples

Validated JSON

[(value)] is the parsed value. Break the JSON to see the error under the editor; the value keeps its last valid state until the text parses again.

Valid JSON only.

Valid JSON

{
  "email": true,
  "sms": false,
  "quietHours": {
    "from": "22:00",
    "to": "07:00"
  }
}

Large editor that never loses a value

A large standalone JSON editor with [allowEmpty]="false" : clearing the text does not wipe the stored value, Save stays disabled until the JSON is valid, and typing null clears it on purpose.

Tab indents here; Ctrl+M (Shift+Alt+M on macOS) lets Tab leave the editor.
Saved: {
  "name": "claims-auto-approval",
  "version": 4,
  "rules": [
    {
      "field": "amount",
      "operator": "lte",
      "value": 500
    },
    {
      "field": "customer.tier",
      "operator": "in",
      "value": [
        "gold",
        "platinum"
      ]
    }
  ],
  "actions": {
    "approve": true,
    "notify": [
      "claims-team"
    ]
  }
}

API

Generated from the library source, so it always matches the code.

AtlasJsonEditorComponent atlas-json-editor

InputTypeDefaultDescription
value two-wayunknownnull The parsed JSON value (two-way bindable). Empty text is null .
indent number2 Spaces per indentation level when the value is shown or formatted.
allowEmpty booleantrue Whether empty text is a valid value ( null ). Turn it off when clearing the editor must not wipe a stored value: empty text is then invalid and the value keeps its last valid state (type null to clear).
showFormat booleantrue Show the Format button, which re-indents valid JSON.
placeholder string'' Text shown while the editor is empty. Not a label.
lineNumbers booleantrue Show the line-number gutter.
lineWrapping booleanfalse Wrap long lines instead of scrolling horizontally.
indentWithTab booleanfalse Tab indents instead of moving focus (Ctrl+M switches back). Off by default.
disabled booleanfalse Whether the editor is disabled.
errors readonly ValidationError.WithOptionalFieldTree[][] Validation errors of the bound field. Set by Signal Forms [field] .
required booleanfalse Whether a value is required. Set by Signal Forms [field] .
invalid booleanfalse Whether the field is invalid. Set by Signal Forms [field] . Invalid JSON marks it invalid too.
touched booleanfalse Whether the user has interacted with the field. Set by Signal Forms [field] .
readonly booleanfalse Whether the text is read-only. Set by Signal Forms [field] .
pending booleanfalse Whether async validation is running. Set by Signal Forms [field] .
name string'' Name of the field. Set by Signal Forms [field] .
ariaLabel string | nullnull Accessible name when no visible label names the editor.
inputId string | undefinedundefinedid of the text surface. Inside atlas-form-field the field supplies one.
ariaDescribedBy string | nullnull Extra ids for aria-describedby , merged with the parse error and the form field's hint or error.
editorClass string'' CSS classes on the editor box (set its height here, e.g. h-80 ), merged with its own; yours win on conflicts. Plain class stays on the host, which also holds the Format button and the error line, so a height there would clip them.
OutputPayloadDescription
touchvoid Emits when the editor loses focus, so Signal Forms marks the field touched.
validityChangeboolean Emits the validity once on creation, then false when the text becomes invalid JSON and true when it parses again.

Functions

FunctionDescription
parseJsonText(text: string): AtlasJsonParseResult Parses editor text: empty text is null , anything else must be valid JSON.
stringifyJsonValue(value: unknown, indent: number): string Serializes a value for the editor: null and undefined are empty text.

Types

AtlasJsonParseResult

Result of parsing the editor text.

type AtlasJsonParseResult = { ok: true; value: unknown } | { ok: false; error: string }