Convert lines to a JSON array
Paste five lines, including a Windows path and a line with quotes, and get a valid array of 5 quoted values: C:\data\file.txt comes out as "C:\\data\\file.txt", with nothing to repair by hand. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Text
- alpha A quoted "value" C:\data\file.txt last
- Values
- alpha, A quoted "value", C:\data\file.txt, , last
- Line count
- 5
A single final line break is treated as the natural end of pasted text rather than as an extra empty value.
Why wrapping lines in quotes by hand breaks
Putting quotation marks around each line with a quick search and replace works until real text arrives. A line that contains a double quote ends the value early, a Windows path such as C:\data\file.txt contains backslashes that must be doubled, and a tab or other control character needs its own escape sequence. This converter applies the standard string rules to every line instead: quotes get a backslash, literal backslashes are doubled and control characters are written in a valid form. Accented words, emoji and non-Latin scripts stay readable, because they need no substitution at all.
What counts as one value
Every line is one value, nothing more and nothing less. The converter never splits on commas, semicolons or spaces, and it does not trim the edges of a line, so what you paste is exactly what you get. Unix, Windows and classic Mac line breaks all give the same result. A blank line in the middle becomes an empty value, while a single line break at the very end is ignored. In the example, five lines become five values. Review lists copied from a spreadsheet or a terminal before using them, because a stray space creates a different value.
Paste one string value on each line
Start with ordinary plain text in which every line represents one value. A grocery list, a set of feature flags, filenames copied from a terminal, labels from a spreadsheet column, and identifiers from an email are all suitable inputs. The converter does not split on commas, semicolons, or spaces, so punctuation inside a line stays part of that value.
It also does not trim leading or trailing spaces from individual lines. Unix LF, Windows CRLF, and classic Mac CR boundaries are all recognized and produce the same result. Intentional blank lines in the middle become empty strings in the array.
If pasted text ends with one line break, that final separator is ignored, avoiding the surprising empty element that a text editor’s normal final newline would otherwise create. Submit at least one character; an entirely empty input is rejected instead of silently inventing a value.
What you can do with it
Build a configuration list
Paste environment names, feature flags, or allowed values and receive a valid string array for a configuration file.
FAQ
What happens to blank lines?
Blank lines inside the text become empty strings. One final line break is ignored so it does not add a phantom value.
Does it trim spaces from each line?
No. Leading and trailing spaces are preserved because they may be part of the intended string value.
What happens to quotes and backslashes inside a line?
They are escaped by the standard rules: a double quote gets a backslash in front, a backslash is doubled, and tabs or other control characters become valid escape sequences. So A quoted "value" stays one valid value.
Does a line break at the very end add an empty value?
No. One final line break is treated as the natural end of the paste, so the newline an editor usually adds never creates a surprise empty value. Blank lines in the middle do become empty values.
Are commas inside a line split into separate values?
No. Only line breaks separate values, so commas, semicolons and spaces inside a line stay part of that value. That keeps addresses, labels and sentences that contain commas intact.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/str/lines-to-json-array \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"alpha\nA quoted \"value\"\nC:\\data\\file.txt"}'const res = await fetch("https://api.kit.forhosting.com/str/lines-to-json-array", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"text": "alpha\nA quoted \"value\"\nC:\\data\\file.txt"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/str/lines-to-json-array",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"text": "alpha\nA quoted \"value\"\nC:\\data\\file.txt"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/str/lines-to-json-array", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"text":"alpha\\nA quoted \\"value\\"\\nC:\\\\data\\\\file.txt"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"text":"alpha\nA quoted \"value\"\nC:\\data\\file.txt"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/str/lines-to-json-array", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"text": "alpha\nA quoted \"value\"\nC:\\data\\file.txt"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "str.lines_to_json_array",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Turn a pasted list into a valid JSON array without repairing quotes or backslashes by hand. This converter treats every line as a string, applies JSON escaping, and returns code-ready output alongside the parsed values and line count. It accepts Unix, Windows, and classic Mac line endings, keeps whitespace inside each value, and preserves intentional blank lines.
Let JSON escaping protect the data
Because serialization uses one deterministic pass and no external services, identical input always produces identical output. Each line is serialized with the standard JSON string rules rather than wrapped in quotation marks through a simple replacement. This distinction matters as soon as real text contains a double quote, a backslash, a tab, or another control character. Quotes receive a backslash, literal backslashes are doubled, and control characters use valid JSON escape sequences. Unicode text remains readable because JSON supports Unicode strings directly; names, accented words, emoji, and non-Latin scripts do not need ad hoc substitutions. The `values` field contains the same logical array as structured output, which is useful for automated clients that should not parse a JSON string again. The `line_count` field makes quick checks easy.
Check boundaries before using the array
Review the output when the source came from a spreadsheet, terminal, or document editor, because this tool preserves line content rather than guessing what the author intended. Spaces that look harmless can create distinct strings, and an internal blank line intentionally becomes an empty string. By contrast, one terminal line break is treated as document termination and does not create an extra value. If you need to remove whitespace, delete empty entries, deduplicate values, sort them, or interpret numbers and booleans as JSON primitives, perform those transformations explicitly before or after this conversion. Every produced member is a JSON string, so a line containing `42` becomes the string `"42"`, not the number 42, and a line containing `true` remains text rather than a Boolean. That stable rule prevents accidental type changes. For automated use, compare `line_count` with the expected number of records and consume `values`; for copy-and-paste work, use the formatted `result` directly.
Integration use cases
Prepare API request data
Convert identifiers copied from a report into a JSON array that can be placed in a request body without broken escaping.
Create reliable test fixtures
Turn filenames, labels, and edge-case strings into deterministic fixture data while preserving meaningful spaces and blank entries.
Technical questions
What does it cost?
API execution costs $0.002 per request. The browser version runs locally for free.
Are numbers and booleans converted to JSON primitives?
No. Every input line becomes a JSON string, so `42`, `true`, and `null` remain quoted text values.
How are quotes and backslashes handled?
Standard JSON serialization escapes them correctly, along with tabs and other control characters, so the result remains valid JSON.