Skip to content
YAS.SH
Developer🌐 YAS server-sideAPI availableintermediate

CSV → JSON

Parses CSV rows — including quoted fields, embedded commas and newlines — into JSON.

Processed by YAS · not stored
Ready to runInstant execution
All tools →
Result

What does this tool do?

Parses CSV rows — including quoted fields, embedded commas and newlines — into JSON.

Why would I use it?

  • A proper CSV parser is needed for real-world exports with quoting.
  • You are scripting an import and need structured JSON.
  • You want to validate that a CSV is well-formed.

Real-life example

Input
name,note
Ada,"said ""hello"", world"
Output
[{"name":"Ada","note":"said \"hello\", world"}]

Quoted fields with commas and escaped quotes parse correctly.

Input → Process → Output → Next

Input
Paste CSV.
Process
YAS applies RFC-4180-style parsing (quotes, escapes, newlines).
Output
JSON array of objects.
Next action
Pipe the JSON into your pipeline or a JSON formatter.

Common mistakes

  • Mixing comma and semicolon delimiters.
  • CRLF vs LF line endings breaking a naive split.
  • Expecting type coercion — numbers stay strings.

What the result means

The JSON preserves the exact field values from the CSV.

Privacy & security

Your input is sent to YAS infrastructure because the tool requires server-side processing or public network queries. Input is not stored.

API

Endpoint
POST https://yas.sh/api/v1/tools/csv-to-json
Request Header
Content-Type: application/json
cURL
curl -X POST "https://yas.sh/api/v1/tools/csv-to-json" \
  -H "Content-Type: application/json" \
  -d '{"input":"name,age\nAnna,30\nBob,25"}'
JavaScript
const res = await fetch("https://yas.sh/api/v1/tools/csv-to-json", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "input": "name,age\nAnna,30\nBob,25"
}),
});
const data = await res.json();
Python
import requests

r = requests.post("https://yas.sh/api/v1/tools/csv-to-json", json={"input":"name,age\nAnna,30\nBob,25"})
data = r.json()
FieldTypeRequiredDescription
inputstringYesCSV text (≤ 64 KB, ≤ 5,000 rows)
delimiterstringNo (default ",")Field delimiter
hasHeaderbooleanNo (default true)First row = keys
Success response
{ "result": { "rows": [{ "name": "Anna", "age": "30" }], "count": 2, "columns": ["name", "age"] } }

Parse CSV (quoted fields, headers) into a JSON array.

Error responses
  • 400 VALIDATION_ERROR — invalid input or unsupported option.
  • 413 PAYLOAD_TOO_LARGE — input exceeds the 64 KB limit.
  • 429 RATE_LIMIT_EXCEEDED — rate limit exceeded (60 req/min).
Limits
  • Maximum input: 64 KB per request.
  • Rate limit: 60 requests/min per IP address.
  • Authenticated accounts benefit from higher tier quotas.

CSV → JSON: technical reference, use cases and FAQ

How CSV → JSON works

Parsing follows RFC 4180: fields are separated by commas, records by line breaks, and any field containing a comma, a quote or a newline must be wrapped in double quotes with embedded quotes doubled. A correct parser is therefore a small state machine, not a line-splitter — splitting on commas breaks the moment a quoted address field contains one, which is why hand-rolled CSV parsing fails on real data.

The first row is treated as a header and becomes the object keys, with each subsequent record emitted as one object. Everything in CSV is text: there are no types in the format, so numeric-looking and boolean-looking values are inferred, and any inference rule will be wrong for some column — leading-zero postcodes, phone numbers and version strings being the usual casualties.

When to use it: real-world scenarios

Loading a spreadsheet export into an API

Finance and ops hand over CSV; the endpoint wants JSON. Converting at the boundary avoids writing a throwaway parser for a one-off import.

Inspecting a large export before importing it

Converting a sample lets you see the actual field names and value shapes, including the trailing spaces and inconsistent casing that break imports downstream.

Seeding test fixtures from real data

A JSON array of objects drops straight into test fixtures, database seeds or mock API responses.

Reshaping data for a JavaScript front end

Charting and table libraries expect arrays of objects. Converting once server-side avoids parsing CSV in the browser on every page load.

Pro tips

  • Check the delimiter before assuming a comma. Exports from European locales frequently use semicolons because the comma is the decimal separator.
  • Watch for a UTF-8 BOM on the first header cell — it silently becomes part of the first key name and breaks every lookup against it.
  • Keep identifiers as strings. Order numbers, postcodes and account IDs with leading zeros lose them the moment they are inferred as numbers.
  • Normalise header names before use. Spaces, casing and trailing whitespace in headers produce object keys that are awkward to access and easy to mistype.

Limitations and edge cases

What this tool deliberately does not do, and where it will disagree with other implementations.

  • A single header row is assumed. Multi-row headers, merged cells and title rows above the data must be removed first.
  • Type inference is heuristic and cannot be disabled per column; verify columns where the string form is significant.
  • Very large files are bounded by memory, since the whole array is materialised rather than streamed.
  • Encodings other than UTF-8 — Latin-1 and Windows-1252 exports are common — will produce mojibake and should be converted first.

Frequently asked questions

How are quoted fields containing commas handled?
Correctly, per RFC 4180: a field wrapped in double quotes may contain commas, newlines and doubled quotes. This is precisely why a naive split on commas corrupts real-world data.
Can I use a semicolon or tab delimiter?
Yes — set the delimiter to match your file. Semicolon-delimited exports are standard in locales that use the comma as a decimal separator.
Why did my postcode lose its leading zero?
It was inferred as a number. Keep such columns as text, since a postcode, phone number or SKU is an identifier that happens to consist of digits, not a quantity.
What happens to rows with the wrong number of fields?
They are reported rather than silently padded, because a short row usually indicates an unescaped delimiter or an unterminated quote earlier in the file.
Ask YAS AI
🍪 Cookies & privacy. Essential cookies keep you signed in and remember language and theme. Google AdSense and reCAPTCHA are Google technologies: AdSense runs only after Accept All; reCAPTCHA loads on sign-in and contact forms. See how Google uses data: https://policies.google.com/technologies/partner-sites cookie policy · privacy policy.
Settings