# Import CSV from Excel or Sheets to JSON with type casting

> Online CSV/TSV ↔ JSON converter free, bidirectional: RFC 4180 parser, delimiter auto-detect (comma, tab, pipe), type casting (int/float/bool).

Free in-browser tool (no upload): https://www.mauriziofonte.it/tools/csv-to-json-converter

**Bidirectional** CSV (or TSV or pipe-separated) ↔ JSON conversion. **RFC 4180-compliant** parser with double-quote escaping, delimiter auto-detect, optional type casting (int/float/bool/null) for JSON output. All local, no server upload.

## How to use the converter

1. **Paste CSV or JSON** - For CSV: one row per record, optional first row as header. For JSON: array of objects (each object = one row). The tool handles CSV with quotes (fields with commas or newlines inside), TSV (tab-separated), pipe-separated.
2. **Pick direction and delimiter** - CSV->JSON or JSON->CSV. Delimiter: auto-detect works with comma, semicolon (Italian/German Excel), tab, pipe. Manual override if auto picks wrong.
3. **Configure headers + cast** - Headers on: the CSV first row becomes JSON object keys. Off: output is an array of arrays. Type cast: strings "42" become number 42, "true"/"false" become bool, empty becomes null.
4. **Export** - Copy to clipboard or download file (.csv or.json). Works with Excel via paste, or direct import into Postgres COPY/MySQL LOAD DATA INFILE for the CSV output.

## Why one more CSV/JSON converter

Three differentiators.

**Correct RFC 4180.** Many online converters mishandle CSV with quotes: `"a,b",c,"d"` must produce 3 fields (`a,b` | `c` | `d`), not 4. Internal quote escaping (`"a""b"` = literal `a"b`) is also frequently buggy. The parser here implements RFC 4180 faithfully: char-by-char state machine, handles quote/escape correctly.

**Delimiter auto-detect.** CSV is convention, not strict standard. Italian/German Excel saves with semicolon (to avoid clashing with the decimal comma). Database exports often use tab (TSV). The tool counts candidate delimiters (,;\t|) in the first 4KB and picks the most frequent. Manual override when needed.

**Optional type casting.** CSV is string-only by design. JSON has native types. The cast "42" -> 42 (number), "true" -> true (boolean), empty -> null is a common shortcut. Disable for CSVs where leading zeros matter (zip codes, fiscal codes, phone prefixes).

## Glossary

- **RFC 4180**: De facto standard for CSV (2005). Defines: line = record, comma = field separator, double quote = field delimiter (for fields with commas/newlines), double quote escaped as "" literally.
- **TSV**: Tab-Separated Values. CSV variant with tab as delimiter. Common for database exports (PostgreSQL COPY default), Excel (clipboard paste) and Hadoop.
- **Type casting**: Automatic conversion of strings to native types (int, float, bool, null) during CSV -> JSON. Regex-matching heuristic, no advanced parsing (dates, currency).
- **Header row**: First CSV row with column names. In JSON output it becomes object keys. Without header, output is an array of arrays (positional).

## Frequently asked questions

### Italian/German Excel saves CSV with semicolons, is that supported?

Yes, both via auto-detect and manual override. Italian/German Excel uses ; as delimiter to avoid clashing with the decimal comma (1.234,56). The tool recognizes the pattern automatically and produces correct JSON.

### Does type casting turn '0123' into 123, losing the leading zero?

Yes, when active. If your CSVs have leading-zero codes (zip codes '00100', fiscal codes), TURN OFF type cast. The tool only matches strict regex (^-?\d+$): '0123' matches and becomes 123. To avoid: cast off.

### Does the JSON->CSV converter handle nested objects?

Partially. Top-level object = row. Nested object inside a field is serialized as a JSON string (e.g. `{"meta":{"a":1}}` -> row with 'meta' field having '{"a":1}' value). For nested objects with re-flattening, preprocessing in Python/jq is better.

### Does it work offline?

Yes, parser and serializer are, no server fetch. Bookmark for offline use.

### Is there a row limit?

Nothing hardcoded. The limit is tab memory. CSVs with 100K rows and 20 columns (~10MB text) run in a few seconds on a modern CPU. For larger datasets: `jq` + `csvkit` CLIs are streaming and handle GBs.

### Numeric fields with European decimal separator (1.234,56)?

Type cast does not recognize them: only matches US format (1234.56). The values stay as JSON strings. For EU number support, preprocessing is needed (sed/awk to swap comma and dot).

### Can I import CSV with BOM (Byte Order Mark)?

Yes. The browser strips the UTF-8 BOM in input. For Excel-friendly CSV output, some prefer CSV with BOM (`\ufeff` at the start): for now the tool produces BOM-less CSV, you can add it manually or convert encoding via iconv.

### Difference between ; and, delimiters?

Regional convention. US/UK: comma. Germany/Italy/France/Spain: semicolon (to avoid clashing with the decimal). Excel picks automatically based on system locale. For max cross-locale compatibility, use TSV (tab) or pipe (|).

---
Tool by Maurizio Fonte, senior backend engineer. All tools: https://www.mauriziofonte.it/tools/
