JSON to One Line
Convert JSON to a single line.
Loading…
About JSON to One Line
Log search boxes, ticket fields, spreadsheet cells and single-line config values do not cope with pretty-printed JSON, because the line breaks split it apart. Paste the document and it comes back as one row of text. A newline inside a string is already written as the two characters \n in valid JSON, so it stays that way and the row never breaks. Conversion runs as you type, and string values and number text are left alone.
Features
- Single-line output with no newline characters
- Newlines inside strings stay escaped as \n
- Converts live while you type
- Valid or Error marker under the input panel
- Copy Output button and a text file download
Limitations
- The whole document goes onto one line; an array of records is not split into one record per line.
- Nesting deeper than 1,000 levels is refused.
- Downloading the result needs a free account; copying it does not.
How it works
- Paste the pretty-printed JSON into the JSON Input panel.
- Watch the Single Line panel fill in as you type; there is no button to press.
- Check the marker under the input: Valid means the text converted, and Error means it is not valid JSON.
- Select Copy Output to take the one-line text, or Download to save it as output.txt.
Example input
{
"id": 42,
"tags": ["json", "compact"]
}Frequently asked questions
- The output is identical: both remove every space and line break outside strings. This page is aimed at the case where you need a single row of text, while the minify page is aimed at shrinking a payload. Use whichever fits your task.
- No. JSON cannot hold a raw line break inside a string, so it is written as the two characters backslash and n. Those characters stay as they are, which means the output contains no real newline.
- Not with this tool. It converts one document into one line, so an array stays a single array. If a pipeline wants one object per line, pass each object through the page separately.
- The output stays empty, a red Error marker appears under the input, and a message explains the problem. Fix the text and the single-line version appears on the next keystroke.
