How to use the list to JS array converter
- Paste your items into List.
- Leave Split on at Detect, or choose New lines, Commas, Semicolons, Tabs or Spaces.
- Choose Quote items: Strings only (numbers unquoted), Single quotes, Double quotes, Backticks or No quotes.
- Set the clean-up options: Trim spaces, Skip empty items, Remove duplicates, Sort A–Z and One item per line.
- Type a Variable name (optional) to get a
constdeclaration, or clear it for a bare array. Copy the JavaScript array.
What it does and when to use it
Hand-quoting dozens of country codes or a column of product SKUs is slow and error-prone: one missing comma or quote breaks the file. Use this tool when you need test data, a lookup list, an allow-list of IDs or menu options in code, and the source is a spreadsheet, a document or a list someone sent you.
For text-only clean-up without code, use remove duplicates or the text sorter. If the data has several columns, CSV to JSON builds an array of objects instead. To turn a finished array into JSON with proper formatting, run it through JS object to JSON.
How it works
The text is split on the chosen separator. Then, in this order, items are trimmed, empty ones are dropped, duplicates are removed keeping the first one, and the list is sorted. Sorting uses natural order, so 2 comes before 10, and capital letters do not jump ahead of small ones. Each item is then written as a literal: in Strings only mode a value that looks like a number, true, false or null is left bare and everything else is double-quoted. Quotes and backslashes inside an item are escaped for the quote character you picked.
Worked examples
The default list. Five lines with a repeat:
apple
banana
cherry
banana
42
become const fruits = ["apple", "banana", "cherry", 42];. The second banana is removed, so Items shows 4, and 42 stays a number.
Semicolons, single quotes, one per line. red; green; blue; 007 with Split on Semicolons, Single quotes, no variable name and One item per line gives:
[
'red',
'green',
'blue',
'007',
]
Each item gets a trailing comma, which JavaScript allows.
Sorting mixed values. Zed 10 2 apple 1 split on Spaces with Sort A–Z gives [1, 2, 10, "apple", "Zed"]: numbers in numeric order first, then words ignoring case.
Limits and tips
- Trailing commas in one-per-line output are fine in JavaScript but not in JSON.
- No nesting. Every item becomes one value; use a CSV tool for rows with several fields.
- Separators inside items are not respected, so
"Smith, John"splits at the comma. Use New lines for such data.
Frequently asked questions
How does Detect choose the separator?
Why is 007 quoted but 42 is not?
Can I paste a column from Excel or Google Sheets?
Are quotes and backslashes inside items escaped?
Can I get JSON instead?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.