induwara.lk
induwara.lkDeveloper · Browser-only

JSON Formatter & Validator — beautify, minify, and fix JSON

Paste any JSON to format, minify, or validate it in your browser. Errors come with line and column numbers. Permissive mode accepts the JSON5 superset — comments, trailing commas, unquoted keys. Nothing is uploaded.

By Induwara AshinsanaUpdated May 11, 2026
JSON Formatter & Validator
Runs in your browser
Output
Parser
Indent
Options

228 characters, 9 lines.

Round-trip verified — output parses back to the same value.

Status
Valid JSON
Round-trip verified
Size change
+18.4%
228 → 270 bytes
Keys
10
4 objects · 1 arrays
Max depth
3
Top-level: Object

How it works

Strict mode runs your input through the browser's built-in JSON.parse — the same implementation Node.js, every modern API client, and every standards-compliant parser uses. Output is produced by JSON.stringify(value, null, indent) for the chosen indent (2 spaces, 4 spaces, or tab), or by JSON.stringify(value) with no third argument for the minified form. Both functions follow RFC 8259 / ECMA-404 to the letter.

Permissive mode adds a small preprocessor that handles the three things people most commonly paste from JavaScript or config files: line and block comments (// and /* */), trailing commas before ] or }, single-quoted strings, and unquoted ASCII object keys. The preprocessor walks one character at a time with a small state machine — never a global regex pass — so a // inside a URL or a comma inside a string is left untouched. The intermediate strict-JSON text is what the actual parser sees, so error positions still line up with your visible input.

Sort-keys is a recursive, depth-first sort of every object's key set using JavaScript's default lexicographic comparator. Arrays are not reordered — JSON arrays are ordered by spec, and reordering them would change the value, not the format. When the toggle is on the output is a canonical form: the same input always produces byte-identical output, which is useful for diffs, signatures, and deterministic build artefacts.

Every successful run is silently round-trip verified: the formatter parses its own output and compares the resulting value structurally to the originally parsed value. If they ever differ the page surfaces a warning under the output. This is the credibility check the page advertises — not just "valid JSON", but "valid JSON whose meaning is identical to your input."

One thing to be aware of: JavaScript represents every number as a 64-bit IEEE-754 float, so integers above Number.MAX_SAFE_INTEGER (9,007,199,254,740,991) silently lose precision when JSON.parse coerces them. The tool detects such values in the source text and warns under the output. For large IDs, the standard workaround is to serialise them as JSON strings on the producing end.

Worked examples

Beautify a minified payload

Input

{"name":"induwara.lk","tools":2,"build":{"framework":"next","version":16}}

Output

{
  "name": "induwara.lk",
  "tools": 2,
  "build": {
    "framework": "next",
    "version": 16
  }
}

Strict mode, 2-space indent. 73 bytes in, 124 bytes out — beautify always grows.

Fix a config snippet copied from JavaScript

Input

// app config
{
  port: 2060,
  hosts: ['localhost', '127.0.0.1',],
  debug: true,
}

Output

{
  "port": 2060,
  "hosts": [
    "localhost",
    "127.0.0.1"
  ],
  "debug": true
}

Permissive mode strips the comment, quotes the keys, converts single quotes, drops the trailing commas — and the output is now strict RFC-8259 JSON.

Pinpoint a missing brace

Input

{
  "user": "induwara",
  "meta": {
    "city": "Colombo"

}

Output

Error · line 6, column 1
Hint: The input ends before a value, bracket, or brace is closed. Check for a missing }, ], or ".

Strict mode reports the position where the parser first ran out of input. The hint helps narrow down what to add — here, the inner "meta" object never closed.

Frequently asked questions

Sources & references

The parser implementation is the browser's native JSON.parse; the only custom code is the permissive-mode preprocessor and the formatter wrapper. Specifications last reviewed on 2026-05-11.

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] — most fixes ship within 24 hours.