JSON Tools
JSON Minifier
Compact valid JSON without changing its data.
Input stays in this browser while you use the tool.
About this tool
The JSON Minifier removes the spaces, tabs and line breaks that make JSON easy to read and leaves only the data. The result is the same JSON written on a single line, which is shorter and easier to send, store or embed.
JSON ignores whitespace between its tokens, so removing it does not change what the data means. Every key, value and array item stays in its original order. Whitespace inside a string is part of the value, so it is kept exactly as it was.
Minified JSON is meant for machines, not for people. Use it when size or a single-line format matters, and keep a readable copy of the original for editing. If you need the readable version back, paste the minified text into the JSON Formatter.
The tool reads your text before rewriting it, so the input must be valid JSON. Everything runs in your browser and the text is not sent to the BitToolsKit server.
Use cases
- Shrink an API request or response body. Indentation can make up a noticeable part of a formatted payload. Removing it reduces the bytes sent.
- Embed JSON in HTML or a script. A single-line value is easier to place in a data attribute, a script tag or a template.
- Store JSON in a database column or in browser storage. A compact value takes less space and has no stray line breaks.
- Put JSON on one line for logs. Many log systems treat each line as one event, so a single-line payload is easier to search and parse.
- Prepare a value for a command line or a test. A one-line JSON string is easier to paste into a command, a curl request or a test case.
- Compare payloads fairly. Minify two versions of the same data to check whether they differ in content or only in formatting.
How to use
- Paste your JSON into the Input box. It can be formatted, partly formatted or already compact.
- Click Run tool.
- Read the single-line result in the Output box.
- If a message appears instead of a result, the input is not valid JSON. Fix the problem it points to and run the tool again.
- Click Copy output to copy the compact JSON, or Download to save it as a file.
- Click Clear to start again with new data.
Keep your original, formatted JSON somewhere safe. Minifying removes the indentation, and editing a long single line is much harder than editing the formatted version.
Examples
Example 1: Formatted object
Input (50 characters):
{
"id": 101,
"name": "Ada",
"active": true
}Output (37 characters):
{"id":101,"name":"Ada","active":true}Example 2: Spaces inside strings are kept
Input:
{"title": "Hello World", "tags": ["a", "b"]}Output:
{"title":"Hello World","tags":["a","b"]}Example 3: Invalid JSON
Input:
{"a": 1, }Output: No compact result. An error message appears because of the comma before the closing brace. Remove the comma and run the tool again.
Common errors
An error message appears instead of a compact result
The input is not valid JSON. Common causes are a trailing comma, single quotes, unquoted keys and missing brackets. Fix the syntax first. The JSON Validator can help you find the problem.
JSON with comments
Standard JSON has no comments. Remove // and /* */ parts before minifying. Some formats such as JSONC allow comments, but this tool expects strict JSON.
JavaScript object syntax instead of JSON
Text such as {name: 'Ada'} is a JavaScript object, not JSON. Put double quotes around keys and strings: {"name":"Ada"}.
The output is still much larger than expected
Minifying only removes whitespace. Long keys, repeated values and large strings stay as they are. For bigger savings, shorten the data itself or let the server compress responses with gzip or Brotli.
The minified result is hard to read or edit
That is expected. Edit the formatted original and minify again afterwards, or paste the compact text into the JSON Formatter to read it.
Minifying text that has several JSON values, such as JSON Lines
The tool expects one JSON value. Minify each line separately, or wrap the items in an array before pasting.
Minified JSON pasted into a JSON string breaks
If you place JSON inside another string, for example in code, the double quotes need escaping with a backslash. Minifying does not escape anything for you.
A very long number changes
Integers larger than 9007199254740991 can lose precision when read as JavaScript numbers. If every digit matters, keep such values as strings in the source data.
The result wraps over several lines in an editor
The tool outputs a single line. Some editors only display a long line wrapped. Turn off soft wrapping, or check the character count, to confirm there are no real line breaks.
An invisible character at the start causes an error
Text copied from files or web pages can include a byte order mark or a non-breaking space. Retype the first characters, or paste through a plain-text editor first.
Frequently asked questions
What does a JSON minifier do?
It removes the spaces, tabs and line breaks between JSON tokens and returns the same data on one line. The keys, values and their order stay the same.
Does minifying change my data?
It does not add or remove keys or values, and it does not change the order or the text inside strings. Because the tool reads and rewrites the value, number formatting can be normalised, so 1.0 may appear as 1. The meaning stays the same.
How much smaller will my JSON get?
That depends on how much indentation the original has. Deeply nested, heavily indented JSON shrinks more. Compact JSON that was already written on one line stays almost the same.
What is the difference between minifying and compressing?
Minifying removes whitespace and gives you smaller, still readable JSON text. Compressing, such as gzip, encodes the bytes in a different form that must be decompressed before use. Servers often do both.
Is minified JSON still valid JSON?
Yes. Any parser reads it exactly like the formatted version.
Can I get the original formatting back?
The exact original indentation is not stored, but you can paste the minified JSON into the JSON Formatter to produce a readable layout again.
Should I minify the JSON files in my project?
Usually not. Keep source files readable so that people can review changes. Minify the copy you send over a network or embed in a page.
Is my JSON sent to a server?
No. The tool runs in your browser and works on your device. As a general habit, avoid pasting passwords, API keys or private tokens into any online tool.