ToolHub

JSON Formatter

Format, validate, and minify JSON

Input

Output

Overview

Format, validate, and minify JSON instantly

JSON (JavaScript Object Notation) is the most common data format on the modern web. Every API response, every configuration file, every NoSQL document is likely JSON. When something goes wrong with JSON it is usually one of three things: a missing comma somewhere in a long blob, a stray quotation mark inside a string, or formatting that makes it impossible to read. ToolHub JSON Formatter solves all three with a single paste.

The formatter validates your JSON, beautifies it with consistent indentation, or minifies it for production with the smallest possible payload. All processing happens in your browser using the native JSON parser, so it is fast and completely private.

Step-by-step

How to use the JSON formatter

  1. 1

    Paste your JSON

    Drop messy or compressed JSON into the input panel. It can be pulled from an API response, a log file, a database export, or anywhere else.
  2. 2

    Beautify or minify

    Beautify adds 2-space indentation and line breaks for human reading. Minify strips all whitespace for the smallest possible payload, used in production APIs and config files.
  3. 3

    See errors immediately

    If your JSON has a syntax error, the output panel shows the exact problem with the location and a description so you can find and fix it quickly.
  4. 4

    Copy the result

    Click copy to grab the formatted output. Paste it directly into your code, your editor, or a file.

Use minify before sending JSON over the wire

Whitespace adds nothing to the data but can be 20 to 50 percent of the file size on heavily indented JSON. For production APIs and embeds, minify before shipping.

Background

What JSON looks like

JSON has six data types: string, number, boolean, null, array, and object. Strings are wrapped in double quotes. Objects use curly braces with key-value pairs. Arrays use square brackets. Everything is comma-separated.

Common JSON mistakes

  • Trailing commas: JSON does not allow them. {"a": 1,} is invalid even though most languages accept it in code.
  • Single quotes: JSON requires double quotes only. 'hello' is invalid; "hello" is correct.
  • Comments: JSON has no comment syntax. // and /* */ both fail.
  • Unquoted keys: object keys must be in quotes. {a: 1} is invalid; {"a": 1} is correct.
  • Special numbers: NaN, Infinity, and -Infinity are not valid JSON values.
  • Hex numbers: 0xff is not valid. Use decimal 255.

JSON vs JavaScript object literal

They look similar but JSON is stricter. Every JSON value is a valid JavaScript expression, but not every JavaScript object is valid JSON. JSON requires double quotes on keys and strings, forbids trailing commas, comments, and special values.

Use cases

When to use this tool

Debugging API responses

Paste a raw response and instantly see whether it parses, then beautify for inspection.

Inspecting log lines

Server logs often contain compact JSON. Beautify makes it readable so you can find the problem.

Config file authoring

Write package.json, tsconfig, .eslintrc, and similar files with confidence that they parse.

Database export reviews

Mongo and other NoSQL exports come as JSON. Beautify long records to verify content.

Fixing copy-paste errors

Validation catches missing commas, mismatched braces, and stray characters that make JSON invalid.

Optimizing API payloads

Minify large JSON files before embedding in HTML or sending over the wire to reduce bandwidth.

Common questions

Will the formatter modify my data?

No. The formatter parses your JSON and re-serializes it with new whitespace. The actual data (numbers, strings, structure) is identical. Beautified and minified versions of the same input always produce identical results when parsed.

Why does my number lose precision?

JavaScript represents all numbers as 64-bit floats, which cannot store integers larger than 2^53 - 1 exactly. If you have very large integers (like Twitter IDs or financial values in cents), they may lose precision after parsing. For these, store as strings.

Is there a size limit?

No hard limit. The browser parses everything, so very large files (over 100 MB) may slow down or run out of memory.

Does this strip comments?

JSON does not have comments to strip. If your input has // style comments, the parser will reject it as invalid JSON. For JSONC (JSON with Comments), use a different parser.

100% private

Privacy and security

JSON is parsed locally

The formatter uses the browser native JSON.parse and JSON.stringify. Nothing is uploaded. Sensitive data like API keys, tokens, or personal information stays on your device.

Related tools

Frequently asked questions

What's the difference between beautify and minify?

Beautify adds indentation and line breaks for readability. Minify removes all whitespace for the smallest payload size.

Will my JSON be sent anywhere?

No. Parsing and formatting happen entirely in your browser using native JSON APIs.