Overview
Introduction
A plain list of names, IDs, or tags, one per line, is easy to paste from anywhere but isn't valid JSON on its own.
This tool turns exactly that kind of newline-separated list into a proper, pretty-printed JSON array of strings.
What Is List to JSON Converter?
A converter that splits plain text into lines, trims each one, discards blanks, and serializes the remaining lines as a JSON array of strings.
It's the inverse of JSON to List for the common case of a flat array of strings, deliberately simpler than Split String into JSON Array since it only ever splits on newlines.
How List to JSON Converter Works
The input is split on \n, each resulting line is trimmed of leading/trailing whitespace, and any line that's empty after trimming is dropped from the result.
The remaining lines, in their original order, are passed to JSON.stringify with the requested indentation (2 spaces by default, or a custom number/tab) to produce a pretty-printed array.
When To Use List to JSON Converter
Use it when you have a plain list, pasted from a spreadsheet column, a text file, or typed by hand, and need it as a proper JSON array.
It's also a quick way to build a small JSON array literal for a config file or test fixture without hand-typing quotes and commas.
Often used alongside JSON to List Converter, String to JSON Array Converter and JSON Array Flattener.
Features
Advantages
- Simple, predictable newline-only splitting with no delimiter configuration to get wrong.
- Automatically trims whitespace and drops blank lines, so messy pasted input still produces a clean array.
- Produces properly quoted, pretty-printed JSON ready to paste directly into code or a config file.
Limitations
- Only splits on newlines, if your source list is comma- or tab-separated instead, use Split String into JSON Array, which supports a custom delimiter.
- Every item becomes a string; there's no automatic detection or conversion of numeric- or boolean-looking lines into their native JSON types.
Examples
Best Practices & Notes
Best Practices
- Use Split String into JSON Array instead if your source data is separated by something other than newlines, like commas or semicolons.
- Trim your source list of stray blank lines before pasting if you want to double check nothing unexpected gets dropped.
- Round-trip through JSON to List to confirm the conversion matches your original list.
Developer Notes
Blank-line filtering happens after trimming, not before, so a line containing only whitespace is correctly treated as blank and dropped, rather than surviving as an empty-looking but technically non-empty string.
List to JSON Converter Use Cases
- Turning a pasted spreadsheet column into a JSON array for a config file
- Building a quick JSON array literal from a list typed by hand
- Converting a plain-text export (one record per line) into JSON for further processing
Common Mistakes
- Expecting a custom delimiter to work; this tool only splits on newlines, use Split String into JSON Array for other delimiters.
- Assuming numeric-looking lines become JSON numbers; every line becomes a JSON string regardless of its content.
- Not noticing that blank lines are silently dropped, which is usually desired but worth knowing if line count matters to you.
Tips
- Use the tab indent option if you're pasting the result into code that uses tabs for indentation.
- Pair with JSON to List to verify a round-trip conversion preserves your original list exactly.