← Back to tool

Collapse · Single line · Paste

JSON to One Line

Updated: June 2026

Some places only accept a single line of text: an environment variable, a CSV cell, a URL parameter, a one-line secret field. Converting multi-line JSON to one line removes every newline and indent so the whole structure fits on a single row while staying perfectly valid.

Collapse to One Line →

Free · No upload · Instant in the browser

One line, still valid JSON

Collapsing JSON to one line is the same operation as minifying: the parser reads your document and re-serialises it with no insignificant whitespace, which by definition means no line breaks. The output is one continuous string of valid JSON. Nothing about the data changes — you can expand it back to a readable layout whenever you need to.

The difference from "minify" is mostly intent. People search for "one line" when the goal is to fit JSON into a field that cannot contain newlines, rather than to shave bytes. The result is identical, and this tool handles both framings.

Where a single line is required

  • Environment variables — a .env value or a secret in a CI system must be one line; a multi-line JSON config has to be collapsed first.
  • URL query parameters — JSON passed in a query string cannot contain raw newlines and must be compact before URL-encoding.
  • Spreadsheet cells — pasting JSON into a single CSV or spreadsheet cell needs it on one line to avoid breaking the row.
  • Log lines — structured logging expects one JSON object per line so each event parses independently.
  • Database columns — storing a config blob in a single text field is cleaner as one line.

Don't just delete the newlines

It is tempting to fix this with a find-and-replace that strips line breaks, but that is risky. A newline inside a string value is significant and must be preserved as \n, not deleted; blindly removing newlines can corrupt your data or merge tokens that needed separating. A proper one-line converter parses the JSON first, so string contents are handled correctly and the structural whitespace — and only the structural whitespace — is removed. That is why the safe path is to re-serialise rather than to search-and-replace.

Reversible and local

Going to one line is lossless: switch to Beautify and the single line expands back into an indented tree with no data lost. So you can store or transmit the compact form and pretty-print it whenever a person needs to read it. As always, the conversion runs in your browser. The JSON you paste — including configs full of credentials — is collapsed locally with no upload, and the one-line result is on your clipboard a click later.

Frequently asked questions

How do I put JSON on one line?

Paste it and choose the Minify tab. All line breaks and indentation are removed and the JSON becomes a single valid line, ready to copy.

Is single-line JSON still valid?

Yes. Only insignificant whitespace is removed, so the one-line output parses to exactly the same value.

Can I expand it back to multiple lines?

Yes. Use the Beautify tab to re-indent the single line into a readable layout at any time.

Why not just delete the line breaks myself?

Newlines inside string values are significant. The tool parses the JSON so those are preserved correctly while structural whitespace is removed.