Xerobit

List to JSON Converter

Paste a list of items, one per line, and this tool converts them into a valid JSON array. You can control quoting, indentation and whether blank lines are skipped. The conversion runs entirely in your browser, so nothing is uploaded to any server.

JSON output

[]

How to use the list to json converter

  1. Paste or type your list into the text area, placing one item on each line.
  2. Choose Double quotes for standard JSON or Single quotes if you need a JavaScript-style array.
  3. Pick an indentation level: compact, 2 spaces, 4 spaces or tab.
  4. Toggle Skip blank lines and Trim whitespace to clean up messy input.
  5. Copy the resulting JSON array from the output box.

How the list to json conversion works

The converter splits your input on newline characters (\n or \r\n). Each resulting line becomes one string element in a JSON array. Before insertion, the tool optionally trims leading and trailing whitespace and removes empty lines.

Special characters inside each item are escaped according to the JSON specification. Backslashes become \\, double quotes become \", and control characters like tabs and newlines are replaced with their escape sequences (\t, \n). For example, the line say "hi" becomes "say \"hi\"" in the output.

When you select single quotes, the escaping rules adjust: single quotes are escaped as \' while double quotes remain literal. This produces a valid JavaScript array expression rather than strict JSON, which some APIs and configuration files accept.

Formatting options explained

Indentation controls readability. Compact mode places everything on one line with no extra spaces, which minimizes file size. Choosing 2 or 4 spaces adds a newline after the opening bracket, indents each element, and places the closing bracket on its own line. Tab indentation works the same way but uses the \t character instead of spaces.

The Trim whitespace option removes spaces and tabs from the start and end of each line before quoting. If your data relies on intentional leading or trailing spaces, disable this option.

The Skip blank lines option filters out lines that are completely empty or contain only whitespace (after trimming). When disabled, those lines become empty strings ("") in the resulting array.

Common use cases

Developers frequently need to turn a column of values copied from a spreadsheet or log file into a JSON array for API payloads or configuration files. This list to json converter handles that in seconds without writing a script.

Another common scenario is preparing data for tools that expect JSON input. If you have a list of IDs, email addresses or tags, converting them to a JSON array lets you paste directly into request bodies or test fixtures.

For structured data formats beyond simple lists, other converters exist. If your source is comma-separated, use the CSV to JSON tool. For key-value pairs in environment files, try env to JSON. Tab-separated values can go through TSV to JSON.

Edge cases and pitfalls

Pasting a single item with no newline still produces a valid one-element array. Pasting nothing at all (or only blank lines with skipping enabled) yields an empty array [].

Unicode characters, including emoji and non-Latin scripts, pass through unchanged. JSON natively supports UTF-8, so no special encoding step is needed.

A frequent mistake is forgetting to escape quotes when manually building JSON strings. Letting this tool handle the escaping avoids syntax errors caused by unescaped double quotes inside values.

If your list contains items that look like numbers (42, 3.14), they are still output as quoted strings. JSON distinguishes between string and number types, and since the input is plain text, every item is treated as a string. Convert types afterward if your application requires numeric values.

Worked examples

ExampleInputResult
Fruit listList items (one per line): apple / banana / cherry; Quote style: double; Indentation: 2; Skip blank lines: yes; Trim whitespace from each item: yes[ / "apple", / "banana", / "cherry" / ]
Compact single quotesList items (one per line): red / green / blue; Quote style: single; Indentation: 0; Skip blank lines: yes; Trim whitespace from each item: yes['red','green','blue']
List with blanks and spacesList items (one per line): one / two / three ; Quote style: double; Indentation: 4; Skip blank lines: yes; Trim whitespace from each item: yes[ / "one", / "two", / "three" / ]

FAQ

Is the output valid JSON?

Yes, when you select double quotes the output conforms to RFC 8259. All special characters are properly escaped. Single-quote mode produces a valid JavaScript array expression, which is accepted by most parsers but is not strict JSON.

Can I convert numbers instead of strings?

This tool treats every line as a string and wraps it in quotes. If you need numeric JSON values, remove the quotes in a text editor afterward or parse the strings in your application code.

What happens if my list has thousands of lines?

The conversion runs locally in your browser using simple string operations, so it handles large lists quickly. There is no upload limit because nothing leaves your machine.

Does it handle Windows line endings?

Yes. The tool normalizes both CRLF (Windows) and LF (Unix) line endings before splitting, so pasting from any source works correctly.

Why would I use single quotes instead of double quotes?

Some configuration systems and older JavaScript APIs expect single-quoted strings. Strict JSON requires double quotes, but single-quote mode is useful when targeting those specific environments.

Are blank lines included in the output?

By default, blank lines are skipped. If you uncheck the Skip blank lines option, each blank line becomes an empty string element in the array.