Skip to content

JSON Formatter & Validator

Paste JSON to beautify, validate or minify it. Errors are pinned to the exact line and column, and everything runs in your browser, so nothing is uploaded.

✓ Valid JSON17 keys · depth 3 · 366 B in → 519 B out

Output
{
  "latitude": 6.4541,
  "longitude": 3.3947,
  "timezone": "Africa/Lagos",
  "current_units": {
    "temperature_2m": "°C",
    "weather_code": "wmo code"
  },
  "current": {
    "time": "2026-10-24T19:00",
    "temperature_2m": 28.3,
    "weather_code": 2,
    "is_day": 0
  },
  "daily": {
    "time": [
      "2026-10-25",
      "2026-10-26"
    ],
    "temperature_2m_max": [
      31.2,
      30.8
    ],
    "precipitation_probability_max": [
      45,
      60
    ]
  },
  "cached": false,
  "source": null
}

How to format JSON online

  1. Paste your JSON into the Input box, upload a .json file, or click Sample to try it.
  2. The formatted result appears instantly on the right. Choose Beautify (2 spaces, 4 spaces or tabs) or Minify.
  3. If the JSON is invalid, the status bar shows what’s wrong and where. Click Jump to error to select the problem character.
  4. Tick Sort keys to order object keys alphabetically, which makes two responses easy to compare.
  5. Copy the result or download it as a .json file.

Beyond formatting, the status bar counts keys and nesting depth and warns about numbers that are too large for JavaScript to keep exactly. That’s a common source of mysteriously changing IDs.

Common JSON errors and how to fix them

ErrorInvalid exampleFix
Trailing comma{"a": 1, "b": 2,}Remove the comma before } or ].
Single quotes{'name': 'Ada'}Use double quotes for keys and strings: {"name": "Ada"}.
Unquoted keys{name: "Ada"}Quote every key. That's JavaScript object syntax, not JSON.
Smart quotes{“name”: “Ada”}Curly quotes from Word, Slack or Notes aren't valid. Retype them as straight quotes.
Comments{"a": 1 // note}JSON has no comments. Remove them, or use JSONC/JSON5 where your tool supports it.
NaN, Infinity, undefined{"score": NaN}Not valid JSON values. Use null or a number.
Two top-level values{"a":1}{"b":2}Wrap them in an array, or treat the data as JSON Lines (one value per line).

Pretty-print JSON in code

Need to format JSON in a script or pipeline instead? Every major language can do it in one line:

JavaScript
const pretty = JSON.stringify(data, null, 2); // 2-space indent
const minified = JSON.stringify(data);

// Format a raw JSON string
const formatted = JSON.stringify(JSON.parse(raw), null, 2);

Practise on real API responses

Most public APIs return minified JSON. Paste a response from one of these free APIs (none needs a key) to see its structure:

  • Open-Meteo: weather forecasts, nested objects of arrays.
  • PokéAPI: deep, large responses, a good test for big JSON.
  • JSONPlaceholder: fake posts, users and todos for testing.
  • Cat Facts: tiny, simple responses for first experiments.
  • REST Countries: country data with names, currencies and flags.

Want types for that response? Use JSON to TypeScript & Zod. Browse every API that needs no key, or read what a public API is if you’re new to them.

Frequently asked questions

Is my JSON sent to a server?

No. Formatting and validation run entirely in your browser with JavaScript's built-in JSON parser. Nothing you paste is uploaded or logged. Your last input is remembered only in this browser's local storage, and Clear removes it.

What's the difference between a JSON formatter and a JSON validator?

A validator checks that text is valid JSON and tells you where it isn't. A formatter (or beautifier) re-indents valid JSON so it's readable. This tool does both at once: it validates as you type and shows the formatted result when the JSON is valid.

Why is my JSON invalid when it looks fine?

The usual culprits are a trailing comma, single quotes, unquoted keys, or curly 'smart' quotes pasted from a document or chat app. The error message shows the line and column; click Jump to error to select the exact character.

Can JSON have comments?

No. Standard JSON (RFC 8259) doesn't allow comments. Some tools accept JSON with comments (JSONC, used by VS Code settings) or JSON5, but APIs and JSON.parse will reject them.

Why did a large number change after formatting?

JavaScript numbers are 64-bit floats, so integers bigger than 9,007,199,254,740,991 (2^53 - 1) lose precision when parsed. The formatter warns you when this happens. APIs usually send big IDs (like tweet or order IDs) as strings for this reason.

How big a file can I format?

Several megabytes work comfortably; the limit is your browser's memory. Syntax colouring switches off above about 300 KB of output to keep typing smooth.

When should I minify JSON?

Minify when sending or storing JSON (API payloads, config embedded in code, localStorage) to save bytes. Beautify when reading, debugging or committing JSON that people will review.

More free developer tools