How to convert text lines into a JSON array

Convert text lines to a JSON string array and back, preserving spaces and duplicates.

Practical guideUpdated Approx. reading time: 4 min
On this page

Format and limits

Each line becomes a string: 001 keeps its leading zeros and true does not become a boolean. Leading and trailing spaces, order, internal blank lines and duplicates are preserved. One final newline terminates the last line rather than adding another element. Reverse conversion accepts only arrays of strings and rejects strings containing line breaks because these would be indistinguishable from additional rows. Text output ends with a newline to preserve a final empty element on a round trip. Limits are 100,000 characters and 10,000 items. The tool does not parse CSV columns or automatically remove duplicates. Use the CSV converter for structured tables.

Step-by-step example

Load the three example lines and convert. The first must appear as "001", with quotes and both zeros; Ana must appear twice. Choose reverse conversion and paste the generated array. You recover three lines with a final newline. Entering [1,2] in that mode is rejected because it contains numbers.

001
Ana
Ana
→
[
  "001",
  "Ana",
  "Ana"
]
  1. Enter your data or load the tool’s example.
  2. Choose the options and press the main button.
  3. Check the result before copying or downloading it.

Copy, download and repeat

Start with the example and observe the relationship between input and output before pasting a complete document. The example is deliberately small so that you can check it without another application. Then replace its data with a representative sample of your case and adjust the options. The main button performs the operation; loading the example only fills the controls. If you modify any input after calculating, the previous result is hidden so that you do not copy a version that no longer corresponds to the data. Run the operation again after every change. Clear restores the initial form values and discards the result on the page. Copy places the output text on the clipboard when the browser allows it. Download creates a file only when you explicitly request it; calculating does not start downloads. Keep a separate copy of the input if you need to repeat the work later, because this form is not a project archive and does not maintain an operation history.

Review before sharing

Check a short sample whose result you can predict and another case containing the details that matter for your work. Inspect both the beginning and the end of the output; an apparently correct result may belong to an earlier input if you have saved several copies outside this page. If an error appears, reduce the sample until you find the offending data and review the stated limits. Do not remove information merely to dismiss a warning: first check whether the chosen operation represents what you need. Before using a download in another program, open it and inspect its characters, structure and values. The file contains the result rather than the form settings. If you need to explain how it was produced, retain the input and the options used as well.

TRY IT YOURSELF

Step-by-step example

Load the three example lines and convert. The first must appear as "001", with quotes and both zeros; Ana must appear twice. Choose reverse conversion and paste the generated array. You recover three lines with a final newline. Entering [1,2] in that mode is rejected because it contains numbers.

001
Ana
Ana

[ "001", "Ana", "Ana" ]

Each line becomes a string: 001 keeps its leading zeros and true does not become a boolean. Leading and trailing spaces, order, internal blank lines and duplicates are preserved. One final newline terminates the last line rather than adding another element. Reverse conversion accepts only arrays of strings and rejects strings containing line breaks because these would be indistinguishable from additional rows. Text output ends with a newline to preserve a final empty element on a round trip. Limits are 100,000 characters and 10,000 items. The tool does not parse CSV columns or automatically remove duplicates. Use the CSV converter for structured tables.