JSON formatter & validator

Format or minify JSON, compare two JSON values structurally, or generate TypeScript interfaces from an object-shaped JSON document.

Need more than a template?

Need something built around this?

I build internal tools, integrations and full-stack products for startups and growing teams.

Full-stack engineering →

How to use the JSON formatter and validator

Paste JSON to format it with two-space indentation, minify it, or find out why it is invalid. The compare view lists which keys were added, removed or changed between two documents, and the TypeScript view turns a JSON object into interfaces you can paste into a codebase.

  1. Paste your JSON and choose Format or Minify. If it is invalid, the message from the parser says what went wrong.
  2. To compare, put the second document in the second box and run the comparison. Each difference is listed by path: + for added, - for removed and ~ for changed.
  3. To get types, paste a JSON object and generate TypeScript. The root has to be an object, not an array.

Worked examples

JSON to TypeScript

// input
{"id":1,"name":"Aslam","tags":["devops","ai"],"profile":{"active":true,"score":9.5}}

// output
export interface RootProfile {
  active: boolean;
  score: number;
}

export interface Root {
  id: number;
  name: string;
  tags: string[];
  profile: RootProfile;
}

Nested objects become their own interface, named after the key.

Comparing two documents

// left
{"hello":"world"}

// right
{"hello":"there"}

// result
~ hello: world → there

These are the tool's two starting documents. A key that exists only on the right appears with +, and one that exists only on the left with -.

Mistakes to avoid

  • Trailing commas

    JSON does not allow a comma after the last item. It is the most common reason a hand-edited file fails.

  • Single quotes and comments

    Keys and strings need double quotes, and JSON has no comments. Config files that allow either are usually JSON5 or JSONC, not JSON.

  • Large integers

    JavaScript parses numbers as 64-bit floats, so integers above 9007199254740991 lose precision. IDs that long are safer as strings.

  • Duplicate keys

    The standard allows them but does not say what they mean. JavaScript keeps the last value and drops the rest without a warning.

Questions people ask

How does it decide that JSON is valid?
It parses the text with the browser's built-in JSON parser, the same one your JavaScript code uses, and shows the parser's error message when parsing fails. The wording of that message differs a little between browsers.
Does it send my JSON anywhere?
No. Parsing, formatting and comparing all happen in your browser.
Does it infer optional fields in the TypeScript output?
It generates types from the one document you paste, so every key present is treated as required. If a field can be missing, mark it optional by hand.

Related