CSV to YAML Converter
Convert CSV data to YAML format online. Supports custom delimiters, type inference, quoted fields, and RFC 4180 compliance. Free, instant, client-side.
About
CSV parsing appears trivial until you encounter quoted fields containing delimiters, embedded newlines within double-quoted values, or escaped quotes ("" → "). A naive split on commas will silently corrupt your data. This tool implements an RFC 4180-compliant finite state machine parser that correctly handles all edge cases. It then serializes to YAML with automatic type inference: values like 42 become integers, TRUE becomes a boolean, and empty cells become NULL. Pro tip: always verify your delimiter. European CSVs often use semicolons because the comma serves as a decimal separator in those locales.
The converter operates entirely in your browser. No data leaves your machine. Output conforms to YAML 1.2 specification with configurable indentation (2 to 8 spaces). Note: this tool assumes the first row contains headers. If your CSV lacks headers, enable the "No Headers" option to generate indexed keys (field_0, field_1, etc.). Maximum recommended file size is 10 MB for responsive performance.
Formulas
The CSV parser uses a finite state machine with four states. For each character c at position i, the transition function δ determines the next state:
where S ∈ {FIELD_START, UNQUOTED, QUOTED, QUOTE_IN_QUOTED} and Σ is the input alphabet containing the delimiter d, the quote character q (0x22), newline characters, and all other Unicode code points.
Type inference applies a priority chain to each raw string value v:
where v = the trimmed cell content. YAML output indentation uses n spaces per nesting level, where n ∈ [2, 8]. Strings containing YAML-reserved characters (:, #, {, }, [, ], ,, &, *, !, |, >, ', ", %, @, `) are automatically single-quoted in the output.
Reference Data
| CSV Feature | RFC 4180 Rule | This Tool | Example |
|---|---|---|---|
| Simple field | Unquoted, no special chars | ✓ Supported | hello |
| Comma in field | Must be double-quoted | ✓ Supported | "New York, NY" |
| Newline in field | Must be double-quoted | ✓ Supported | "Line1
Line2" |
| Double-quote in field | Escaped as "" | ✓ Supported | "He said ""hi""" |
| Empty field | Adjacent delimiters | ✓ → null | a,,c |
| Trailing CRLF | Optional on last record | ✓ Trimmed | - |
| Header row | Optional (first record) | ✓ Configurable | - |
| Semicolon delimiter | Not in RFC (common EU) | ✓ Selectable | a;b;c |
| Tab delimiter | TSV variant | ✓ Selectable | a\tb\tc |
| Pipe delimiter | Custom variant | ✓ Selectable | a|b|c |
| Integer detection | - | ✓ 42 → int | 42 |
| Float detection | - | ✓ 3.14 → float | 3.14 |
| Boolean detection | - | ✓ true/false | TRUE |
| Null detection | - | ✓ empty → null | (empty cell) |
| Date detection | - | ✓ ISO 8601 preserved | 2024-01-15 |
| Unicode content | Encoding-dependent | ✓ UTF-8 | 日本語 |
| Whitespace trimming | Not specified | ✓ Configurable | hello |
| YAML indent size | - | 2-8 spaces | - |
| YAML string quoting | - | Auto (special chars only) | "contains: colon" |
| Max file size | - | 10 MB | - |