Skip to content
DayUtils

JSON Formatter and Validator – Beautify, Minify and Check JSON

Paste JSON to pretty-print it with 2 or 4 spaces or tabs, minify it to a single line, or sort its keys alphabetically. If the JSON is invalid, you’ll see the exact line and column of the problem and a plain-English description. Everything runs in your browser.

Loading tool…

How to use the JSON formatter

  1. Paste your JSON into the JSON box, or press Try an example.
  2. Choose the indent: 2 spaces, 4 spaces, tabs, or Minify for a single line.
  3. Tick Sort keys A–Z if you want object keys in alphabetical order.
  4. Copy the result, download it as a file, or press Use as input to keep editing.

The status line confirms the JSON is valid and shows how its size changed.

What makes JSON valid

JSON (JavaScript Object Notation) has a small, strict set of rules:

  • Objects use curly braces, with keys in double quotes: {"name": "Ada"}.
  • Arrays use square brackets: [1, 2, 3].
  • Values can be strings, numbers, true, false, null, objects or arrays.
  • Strings must use double quotes, and special characters such as new lines must be escaped (\n).
  • Items are separated by commas, with no trailing comma after the last one.
  • No comments are allowed.

Example

This is invalid because of the single quotes and the trailing comma:

{'name': 'Ada', 'born': 1815,}

The valid version is:

{"name": "Ada", "born": 1815}

Pretty-print or minify?

Pretty-printed JSON is easier to read, review and debug, so use it in configuration files, documentation and when inspecting API responses. Minified JSON is smaller and faster to send, so it is usually what servers and browsers exchange. Many projects store pretty JSON in source control and let the build minify it.

Common uses

  • Debugging APIs: make a long response readable.
  • Editing configuration: package.json, tsconfig.json, app settings.
  • Checking data before importing it into a database or spreadsheet.
  • Comparing documents: format and sort both, then compare them.
  • Learning: see the structure of nested objects clearly.

Large files

The formatter handles files of several megabytes comfortably on most devices. For very large files, minified output is quicker to produce than pretty output because there is less text to display.

JSON vs JavaScript objects

JSON looks like JavaScript, but it is a stricter data format. JavaScript allows single quotes, unquoted keys, trailing commas, comments and values such as undefined or functions; JSON allows none of these. If you copy an object from JavaScript code into a JSON file, run it through the formatter first — it will point to the exact character that needs fixing. Some tools accept relaxed formats such as JSON5 or JSONC (JSON with comments), used in editor settings files, but standard JSON parsers will reject them.

Numbers deserve a note too: JSON has no special values for infinity or “not a number”, and very large integers can lose precision in JavaScript. If you work with IDs longer than about 15 digits, keep them as strings.

Convert between formats with CSV to JSON and YAML to JSON. Inspect tokens with the JWT decoder, and decode encoded data with the Base64 decoder.

Frequently asked questions

How do I format JSON?

Paste it into the input box. The formatted version appears instantly with the indentation you choose. Use Copy or Download to take it with you.

How do I find an error in my JSON?

If the JSON is invalid, the tool shows the line and column where parsing stopped and what was expected — for example “Trailing comma before }” or “Expected a property name in double quotes”.

What are the most common JSON mistakes?

Trailing commas after the last item, single quotes instead of double quotes, unquoted property names, comments, and missing commas between items. JSON is stricter than JavaScript, so code that works in JavaScript isn’t always valid JSON.

What does minify do?

It removes all unnecessary spaces and line breaks, making the JSON as small as possible for sending over a network or storing.

Is my JSON uploaded anywhere?

No. Formatting and validation happen in your browser. That makes the tool safe for API responses, configuration files and data that contains private information.

Why sort keys?

Sorting object keys alphabetically makes two JSON documents easier to compare, and keeps configuration files tidy. The values and arrays keep their order.

Last updated: