List to JSON Array

Turn a plain list of lines into a JSON array, with sensible type detection and leading-zero codes kept as strings.

Everything runs in your browser, so a list of internal or customer data never leaves your machine.

What It Does

Paste a list with one entry per line and get a JSON array. The conversion is trivial; the judgement is in what gets typed. Numbers become numbers and true and false become booleans, but a value with a leading zero stays a string — because 007 is a code, not the quantity seven, and converting it destroys the value in a way you cannot undo. Blank lines and stray padding from the copy are dropped by default, since a trailing newline would otherwise put an empty string at the end of your array. Beyond the plain array it can deduplicate and tell you how many it removed, and wrap each line as an object under a key you choose, which is the shape most bulk-insert APIs and database seeders expect.

When to Use It

  • A column copied out of a spreadsheet needs to become a JSON array for an API request.
  • You are writing a seeder or a test fixture and have the values as a plain list.
  • A set of allowed values needs to go into a configuration file as an array.
  • You need an array of objects for a bulk insert and have one field per line.
  • You want to know how many distinct values a list actually contains before using it.

Worked Examples

apple banana cherry

The simplest case — three strings become a three-element array. Nothing here is ambiguous, which is why the interesting behaviour only shows up in the next two examples.

42 3.14 true 007

Type detection in action. The first three become a number, a number and a boolean. The last stays the string "007", because dropping that leading zero would turn a code into a different value entirely.

spaced duplicate duplicate

A realistically messy paste. Padding is trimmed, the blank line and the trailing newline are dropped, and turning on deduplication collapses the repeat and tells you one was removed.

Features

One line becomes one array element
Type detection for numbers
booleans and null
Leading-zero codes preserved as strings
Blank lines and trailing newline handled
Per-line whitespace trimming
Optional deduplication with a count of what was removed
Case-sensitive or case-insensitive matching
Optional wrapping as objects under a key you choose
Pretty-printed or compact output
Runs entirely in your browser

How to Use

1. Paste your list, one entry per line. 2. The JSON array appears immediately below. 3. Turn off type detection if the consumer expects every value as a string. 4. Enter a key name to wrap each line as an object instead of a bare value. 5. Copy the result, switching to compact output if it is going somewhere whitespace matters.

Common Mistakes

  • Letting a leading-zero code become a number. Postcodes, product codes and phone numbers lose their zero and become values that match nothing.
  • Forgetting the trailing newline. Without blank-line removal, a paste that ends in a newline adds an empty string to the end of the array.
  • Deduplicating case-sensitively when the data is email addresses. [email protected] and [email protected] are the same person, and the default will keep both.
  • Producing a plain array when the consumer wants objects. Most bulk-insert endpoints expect records with named fields, not bare values.
  • Pretty-printing JSON that is going into a URL or an environment variable. The whitespace is real characters and can push you over a length limit.

Frequently Asked Questions

Explore related topics

#JSON #Converter