ToolNimba

{ } JSON Editor and Validator

Shihab Mia By Shihab Mia ยท Updated 2026-07-01

Checking...
Top-level keys
0
Nesting depth
0
Size (bytes)
0
Characters
0

Edit the JSON above. Validation and stats update as you type.

This JSON editor and validator checks your JSON the moment you type it: a green "Valid JSON" badge appears when the syntax parses, and a red error with the exact parser message appears when it does not. Alongside the editor you get live stats, the top-level key count, the nesting depth, and the byte size, plus one-click Format (pretty-print with 2-space indent) and Minify buttons. Everything runs in your browser, so the JSON you paste never leaves the page.

What is the JSON Editor and Validator?

JSON (JavaScript Object Notation) is the text format that web APIs, config files, and JavaScript apps use to exchange structured data. It is built from just a few pieces: objects wrapped in curly braces with "key": value pairs, arrays in square brackets, strings in double quotes, numbers, the literals true, false and null, and nothing else. The rules are strict on purpose, which is exactly why a tiny mistake, a trailing comma, a single quote, or a missing bracket, breaks the whole document. A validator exists to point at that mistake instead of leaving you to hunt for it.

When you type or paste into the editor above, the tool runs JSON.parse on your text on every keystroke. If parsing succeeds, the value is valid JSON and the badge turns green. If it throws, the badge turns red and shows the browser's own SyntaxError message, which usually names the position where parsing failed. This is the same engine your code will use at runtime, so if it validates here it will parse in your app.

The stats line turns your JSON into three quick numbers. Top-level keys counts the entries at the root: the number of keys if the root is an object, or the number of items if it is an array. Nesting depth is measured recursively, a flat object of scalars is depth 1, an object that contains an array of objects is depth 3, and so on. Byte size is the actual UTF-8 size measured with new Blob([text]).size, which is what matters for payloads and storage, and it can differ from the character count when your JSON contains accented letters, emoji, or other multi-byte characters.

Format and Minify are the two everyday actions. Format runs JSON.parse then JSON.stringify with a 2-space indent, giving you readable, consistently indented output that is easy to diff and review. Minify runs JSON.stringify with no whitespace at all, collapsing the document to a single compact line for API bodies, query values, or anywhere size counts. Both only run on valid JSON, so they double as a validation step.

When to use it

  • Pasting an API response and confirming it is valid JSON before wiring it into your code.
  • Cleaning up a minified or messy config file into readable, 2-space-indented JSON.
  • Minifying a JSON payload to shrink an API request body or a stored config value.
  • Finding the exact character where a hand-edited JSON file breaks, using the live parser message.
  • Checking how deeply nested a document is, or how many top-level keys it holds, before working with it.
  • Measuring the real byte size of a JSON payload to stay under an API or storage limit.

How to use the JSON Editor and Validator

  1. Type or paste your JSON into the editor. A sample object is loaded so you can see a valid result right away.
  2. Watch the badge: green means valid, red shows the exact parser error and where it failed.
  3. Read the stats row for top-level key count, nesting depth, byte size, and character count.
  4. Press Format for readable 2-space indentation, or Minify to collapse it to one compact line.
  5. Press Copy to put the current editor text on your clipboard, or Clear to start over.

Formula & method

Valid = JSON.parse(text) does not throw. Format = JSON.stringify(value, null, 2). Minify = JSON.stringify(value). Top-level keys = Array.isArray(v) ? v.length : Object.keys(v).length. Depth is recursive: scalar = 0, and a container = 1 + max(depth of its children). Byte size = new Blob([text]).size (UTF-8), which can exceed the character count for multi-byte characters.
JSON Editor: validate, format, and measureJSON.parse decides valid or invalid, then stats are computed{"name": "Ada","skills": ["math", "code"],"active": true}Valid JSONTop-level keys3Nesting depth2Size (UTF-8 bytes) via Blob78Format: JSON.stringify(value, null, 2) | Minify: JSON.stringify(value)Everything runs in your browser, nothing is uploaded

Worked examples

You paste an API response and want to confirm it is valid, then read it comfortably.

  1. Paste: {"user":{"id":7,"tags":["a","b"]},"ok":true}
  2. The badge turns green and reads Valid JSON.
  3. Stats show 2 top-level keys (user and ok) and a nesting depth of 3 (root object to user object to tags array).
  4. Press Format to expand it into a readable, 2-space indented block.

Result: Confirmed valid, 2 top-level keys, depth 3, now pretty-printed and easy to scan.

A hand-edited config will not load and you need to find the broken character.

  1. Paste: {"port":8080,"hosts":["a","b",]}
  2. The badge turns red and shows the parser message, which flags the token after the last comma.
  3. The trailing comma before the closing bracket is the problem: JSON does not allow it.
  4. Delete that comma so the array reads ["a","b"].

Result: The badge flips back to green Valid JSON and Format now works on the fixed text.

What the tool measures and how it is computed

StatMeaningHow it is computed
Top-level keysEntries at the rootObject: Object.keys(v).length; Array: v.length
Nesting depthHow deeply values nestRecursive: 1 + max depth of children; scalar is 0
Size (bytes)UTF-8 payload sizenew Blob([text]).size
CharactersNumber of characterstext.length

Common JSON syntax rules that trip people up

RuleAllowedNot allowed
String quotes"double quotes"'single quotes'
Trailing comma{"a":1}{"a":1,}
KeysAlways quoted stringsUnquoted keys like {a:1}
CommentsNone permitted// or /* */ comments
Root valueObject, array, string, number, true, false, nullNothing, or an unquoted word

Common mistakes to avoid

  • Leaving a trailing comma. JSON does not allow a comma after the last item in an object or array. {"a":1,} and [1,2,] are both invalid even though many programming languages accept them. Remove the final comma.
  • Using single quotes. JSON strings and keys must use double quotes. 'name' is invalid; it must be "name". This is the most common error when copying JavaScript object literals into a JSON file.
  • Confusing JSON with a JavaScript object. A JS object can have unquoted keys, comments, trailing commas, and functions. JSON allows none of those. Valid JavaScript is not automatically valid JSON.
  • Assuming byte size equals character count. Accented letters, emoji, and many non-Latin characters take more than one byte in UTF-8. A 10-character string can be 12 or more bytes, which is why the byte and character counts are shown separately.

Glossary

JSON
JavaScript Object Notation: a strict, text-based format of objects, arrays, strings, numbers, and the literals true, false, and null.
Validate
To check that text is syntactically correct JSON. Here it means JSON.parse runs without throwing an error.
Format (pretty-print)
Rewriting JSON with consistent indentation and line breaks so it is easy to read; this tool uses a 2-space indent.
Minify
Removing all optional whitespace so the JSON is a single compact line, useful for smaller payloads.
Nesting depth
How many levels of objects and arrays are stacked inside each other, measured recursively from the root.
Byte size
The size of the text in bytes when encoded as UTF-8, which can be larger than the character count for multi-byte characters.

Frequently asked questions

How do I validate JSON online?

Paste or type your JSON into the editor above. It is validated on every keystroke: a green badge means valid, and a red badge shows the exact parser error message. No button press is needed, validation is live.

What is the difference between Format and Minify?

Format pretty-prints your JSON with 2-space indentation and line breaks so it is easy to read and diff. Minify strips all whitespace to produce a single compact line, which is smaller for API bodies and storage. Both only run on valid JSON.

How is nesting depth calculated?

Depth is measured recursively. A plain object or array of scalars is depth 1. Each additional level of nested objects or arrays adds one, so an object containing an array of objects is depth 3. It is the length of the deepest path from the root.

Why does the byte size differ from the character count?

Byte size is the UTF-8 size measured with new Blob([text]).size, while characters is simply text.length. ASCII characters are one byte each, but accented letters, emoji, and many symbols take two to four bytes, so the two numbers can differ.

Is my JSON sent to a server?

No. All parsing, formatting, minifying, and stats run locally in your browser with vanilla JavaScript. Nothing you paste is uploaded, which makes the editor safe for private tokens, configs, or sensitive data.

Why does my JavaScript object show as invalid JSON?

JavaScript object literals allow things JSON forbids: single quotes, unquoted keys, trailing commas, and comments. Convert them to double-quoted keys and strings, remove trailing commas, and delete any comments to make the text valid JSON.

Sources