Free · Fast · Privacy-first

CSV to JSON Keep Nulls

Empty cells in a CSV are ambiguous: do they mean missing data, an explicit empty string, or a default zero? JSON distinguishes null from empty string from zero, so the conversion has to pick a representation for empty cells.

Native JSON tool

CSV to JSON

Runs in your browser
JSON output
Run the tool to see a task-specific result.

Uniform null for empties

🔒

Schema-consistent output

DB and API friendly

Toggle on or off

Cost
Free tier
Sign-up
Not required
Processing
Tool-specific
Privacy
Clearly disclosed
IframeResponsiveAttribution included

Add this CSV to JSON to your website

Drop the CSV to JSON into a blog post, product docs, intranet, or school portal with one iframe. Processing, privacy, and usage limits are the same as on the full tool page.

  • One copy-ready line of HTML
  • Responsive — adapts to any container width
  • No API credentials are placed in the snippet

Embed code

<iframe
  src="https://www.fixtools.io/json/csv-to-json?embed=1"
  width="100%"
  height="780"
  frameborder="0"
  style="border:0;border-radius:16px;max-width:900px;"
  title="CSV to JSON by FixTools"
  loading="lazy"
  allow="clipboard-write"
></iframe>

Attribution-friendly: a small "Powered by FixTools" link appears in the embed footer.

Choosing null versus empty string

Both null and empty string are valid JSON values that can mean missing. The difference matters when the consumer treats them differently. SQL NULL is a distinct value with three-valued logic; SQL empty string is a string of zero characters that participates in normal string comparisons. JavaScript both null and empty string are falsy in boolean contexts but differ in JSON.stringify output and in equality checks. Picking the right representation for your context avoids subtle bugs where empty cells are interpreted inconsistently.

FixTools default rule is context-sensitive: numeric and boolean columns emit null for empty cells because there is no zero-value representation that means missing, while string columns emit empty string because that is the closer match for textual emptiness. This default works for most use cases but can produce inconsistency across columns. With Keep Nulls enabled, every empty cell becomes null regardless of column type, which is the cleaner choice when consistency matters more than the contextual nuance.

For database loads, Keep Nulls is usually the right choice because columns with NOT NULL constraints are checked against actual null values during INSERT. An empty string slips through a NOT NULL constraint because it is not null, but it may violate a CHECK constraint or business rule that requires non-empty values. By making missing data explicit as null, you can detect schema violations at load time rather than at query time.

For API contracts that specify null for missing fields, Keep Nulls is again the right choice. JSON Schema validation typically distinguishes type string from type null and complains if a field marked null is empty string. Producing null in the converter avoids these validation failures and matches the contract literally. The toggle costs nothing and the consistency is worth the keystroke.

How to use this tool

💡

Toggle Keep Nulls to emit JSON null for every empty cell, regardless of column type.

How It Works

Step-by-step guide to csv to json keep nulls:

  1. 1

    Decide based on consumer schema

    Check whether your consumer expects null or empty string for missing data. Database loads usually want null. APIs often specify null. Frontends sometimes prefer empty string for direct rendering.

  2. 2

    Enable Keep Nulls

    Toggle the Keep Nulls option in the converter before clicking Convert. The setting applies to every empty cell in the conversion.

  3. 3

    Convert and inspect

    Confirm in the preview that empty cells become null. Both numeric and string columns should show null rather than empty string for missing values.

  4. 4

    Validate against schema

    If your consumer uses JSON Schema, validate the output. Schema with type [string, null] accepts both, while strict type [string] would reject null.

  5. 5

    Download

    Save the JSON. The null representation is unambiguous and matches the consumer expectation.

Real-world examples

Common situations where this approach makes a real difference:

Postgres load with NOT NULL constraints

A data engineer loads CSV into Postgres where some columns have NOT NULL constraints. With Keep Nulls, missing cells are caught at load time as constraint violations rather than slipping through as empty strings.

GraphQL response shape

A backend developer prepares fixture data for GraphQL where nullable fields are explicit. Keep Nulls produces fixtures that match the GraphQL schema directly.

OpenAPI specification compliance

An API team requires that missing values be null per their OpenAPI spec. Keep Nulls ensures the converted JSON validates against the spec.

Data warehouse ingestion

A warehouse ETL job differentiates null from empty string for analytics queries. Keep Nulls produces the cleaner representation that the warehouse expects.

Pro tips

Get better results with these expert suggestions:

1

Match the consumer expectation

Pick null or empty string based on what your consumer actually checks. Mixing the two in the same dataset is the worst outcome because consumer code has to handle both. Pick one and stick to it.

2

Document the choice

Add a note to your data documentation specifying that empty cells in the CSV produce null in the JSON. Future maintainers know the convention without re-reading conversion code.

3

Combine with type inference

Keep Nulls plus type inference produces the cleanest result: typed numeric columns with null for missing, typed boolean columns with null for missing, and string columns with null rather than empty string.

4

Test the round-trip

Convert CSV to JSON with Keep Nulls, then JSON back to CSV. Null in JSON becomes empty cell in CSV, which restores the original cleanly. Confirm by diffing the two CSV files.

FAQ

Frequently asked questions

When enabled, every empty CSV cell becomes JSON null regardless of the column type. When disabled, empty cells become null in numeric and boolean columns but empty string in string columns. Keep Nulls produces consistent null for every empty.
Enable when your consumer expects null for missing data, such as database loads with NOT NULL semantics, GraphQL schemas with explicit nullable fields, and OpenAPI specifications that require null. Disable when empty string is the natural representation for missing text values.
Strict typed consumers may reject null where they expect strings. Check the consumer schema and either enable Keep Nulls or disable it based on what the consumer accepts. JSON Schema with type [string, null] accepts both representations.
On round-trip from JSON back to CSV, null becomes empty cell in the resulting CSV. This restores the original shape cleanly. There is no information loss.
Both are falsy in boolean contexts but they have different types: typeof null returns object, typeof "" returns string. JSON.stringify outputs them differently. Equality checks with == treat them as different. Use === for strict comparisons.
Yes. Type inference identifies the type of a column based on non-empty cells. Empty cells become null (with Keep Nulls) without affecting the inferred type. A numeric column has number values plus nulls; a string column has string values plus nulls.
Yes. BSON has a Null type that maps directly to JSON null. mongoimport stores null as BSON Null, which queries with $eq: null match correctly. This is the standard MongoDB way to represent missing field values.
Yes, with jq or a small script. The expression walk(if . == null then "" else . end) recurses through the JSON and replaces null with empty string. This is sometimes useful when feeding a consumer that prefers empty string.
Yes. Empty cells in nested-header columns (like address.city) become null with Keep Nulls enabled. The parent object structure is still created consistently across rows.

Related guides

More use-case guides for the same tool:

Ready to get started?

Open CSV to JSON to review its free limits and processing method.

Open CSV to JSON →

Free tier · No account needed · Transparent limits

Source-backed reference

JSON standards quick reference

Concise, standards-backed facts for developers working with JSON debugging and validation. Each rule links to a primary specification so it can be independently verified before you rely on it in code, documentation, or an incident report.

JSON standard
RFC 8259 defines JSON as a text format for serializing structured data. JSON values may be objects, arrays, strings, numbers, true, false, or null.
Verify in RFC 8259
Strings and object keys
JSON strings and object member names use double quotation marks. Single-quoted strings are not valid JSON syntax.
Verify in RFC 8259 §7
Trailing commas
The JSON grammar does not allow a comma after the final member of an object or the final element of an array.
Verify in RFC 8259 §4–5
Interoperability
ECMA-404 describes the JSON syntax independently of any programming language, which is why standard parsers can exchange the same JSON text across runtimes.
Verify in ECMA-404

Common invalid → valid JSON examples

Trailing comma

{"a":1,}{"a":1}

Single-quoted key

{'a':1}{"a":1}

Unsupported literal

{"score":NaN}{"score":null}

Built for verification, not just extraction

Direct answers are paired with primary sources and concrete examples. That makes this page useful to developers and also gives search and answer systems a clear, verifiable statement to reference instead of an unsupported summary.