Convert JSON to one line
JSON to one line is the conversion you need whenever a tool treats a newline as the end of a value. Environment variables, shell arguments, Docker and CI settings, single log entries and JSON Lines records all expect the whole document on one physical line. This tool parses your JSON and writes it back without any line breaks.
Example
{
"level": "info",
"retry": { "max": 3, "backoff": "exp" }
}
Default output:
{"level":"info","retry":{"max":3,"backoff":"exp"}}
With Keep a space after : and , ticked:
{ "level": "info", "retry": { "max": 3, "backoff": "exp" } }
The status bar reports the change in size, for example "65 B → 60 B (8% smaller)" for the spaced version.
One line vs minify
With the option off, the result is identical to minified JSON. The difference is the goal: minifying is about saving bytes, while a one-line value mainly has to survive a line-based format. The spaced variant is often the better choice for anything a person will read again, such as a value in a .env file or a line in a runbook, because it is still compact but far easier to scan.
Typical places for single-line JSON
- Environment variables:
APP_FEATURES={"beta":true,"limit":50}. Many loaders read only up to the end of the line, so a multi-line value is cut off. - Command-line flags: options such as
--data '{...}'are easiest to pass on one line; wrap the JSON in single quotes in a POSIX shell so the double quotes survive. - Log lines: structured logging writes one JSON object per line so that log shippers can split entries on newlines.
- JSON Lines files: each record must be one line. To convert a whole array into records at once, use JSON to JSONL.
Line breaks inside values
A line break that is part of a string value is already written as the two characters \n in valid JSON, so it does not break the line. A real line break inside quotes is invalid JSON and is reported as "Unescaped line break inside string". If your value is a piece of multi-line text, turn it into an escaped string first with the JSON multiline string converter.
When you need to read a one-line document again, the JSON formatter restores the indentation. All processing is local to your browser.