Skip to content

JSON Formatter & Validator

Pretty-print, minify, sort and validate JSON, keeping every number exactly as written.

Runs in your browser. Nothing is uploaded.

JSON input

Valid JSON
Output
Indent

Formatted JSON

229 bytes, depth 3, 11 keys
{
  "account": {
    "id": "001A0000006Vm9rIAC",
    "name": "Acme Labs",
    "annualRevenue": 1250000.00,
    "active": true,
    "tags": [
      "priority",
      "wholesale"
    ],
    "owner": {
      "name": "Ada Rao",
      "email": "ada@acme.example"
    },
    "externalId": 9007199254740993,
    "contacts": []
  }
}

One thing to check

  • 9007199254740993 is larger than JavaScript can store exactly. It is kept as written here, but many tools will round it. In Apex, read it as a Long or a String.

How to use the JSON Formatter & Validator

  1. Paste JSON into the input, or drop a .json file onto it.
  2. Choose Format, Minify or Apex string, and the indentation you prefer.
  3. Turn on “Sort keys” to order every object’s keys alphabetically, which makes two payloads easy to compare.
  4. Copy the result or download it as a file.

What a JSON formatter does

APIs usually return JSON on a single line to save bytes. A formatter adds line breaks and indentation so you can see the structure: which objects are nested, what each array holds and where a value is missing. Minifying does the opposite, for when you need the smallest possible payload.

Why number precision matters

Many online formatters use JavaScript’s JSON.parse, which turns every number into a 64-bit floating point value. Integers above 9,007,199,254,740,991 are silently rounded, and 1.0 becomes 1. This formatter never converts numbers, so record numbers, external IDs and money values come out exactly as they went in.

Common JSON errors

  • A trailing comma after the last item: [1, 2,].
  • Single quotes instead of double quotes: {'name': 'Acme'}.
  • Keys without quotes: {name: "Acme"}.
  • Comments, which JSON does not allow.
  • A missing comma between two properties.

JSON in Apex

To put JSON in Apex, for example as a test fixture, use Apex string mode. It escapes the single quotes and backslashes for you.

Apex
String jsonBody = '{"name":"O\'Brien","active":true}';
Map<String, Object> data = (Map<String, Object>) JSON.deserializeUntyped(jsonBody);

To turn the same JSON into typed wrapper classes, use the JSON to Apex Class Generator.

Features and limitations

What it does

  • Validates as you type and points to the exact line and column of the first error, with a plain explanation.
  • Keeps numbers exactly as written: 1.0 stays 1.0 and integers too large for JavaScript are not rounded.
  • Warns about duplicate keys, which most parsers silently overwrite.
  • Apex string mode produces String jsonBody = '...'; with every quote escaped, ready for a test or a callout.
  • Shows size, depth and how many objects, arrays and keys the document has.

What it does not do

  • Strict JSON only: comments, trailing commas and single-quoted strings are reported as errors, as Apex would.
  • It does not validate against a JSON Schema.
  • Escapes inside strings may be normalised, for example \u00e9 becomes é. The value is unchanged.

Questions about the JSON Formatter & Validator

No. Parsing and formatting happen in your browser. Nothing you paste is sent anywhere or stored.

Some formatters accept JavaScript-style input such as comments or trailing commas. Apex’s JSON parser and most APIs do not, so this tool reports them as errors.

Only the order of keys inside objects. Arrays keep their order, because array order has meaning.

Files of several megabytes format in well under a second on a typical laptop. Very large files may make the highlighted view slower to scroll.

Format both with “Sort keys” on and the same indentation, then compare them with any text diff tool. The output is stable, so only real differences show up.