SQL to YAML

Convert SQL INSERT rows into YAML.

0 chars
0 words
0 lines
0 chars
0 words
0 lines

SQL to YAML Converter Online

The SQL to YAML converter turns the data in INSERT statements into readable YAML. YAML is popular for configuration, fixtures, and seed files because it is easy to edit by hand and diff in version control — this tool lets you move reference data out of a SQL dump and into that format in seconds.

Example

INSERT INTO roles (id, name, is_admin) VALUES (1, 'owner', TRUE), (2, 'viewer', FALSE);

becomes

- id: 1
name: owner
is_admin: true
- id: 2
name: viewer
is_admin: false

With data for several tables, the output is keyed by table name, so a dump with roles and users produces two top-level sections.

Types survive the trip

SQL literals are converted to native YAML scalars: numbers stay numeric, TRUE/FALSE become booleans, and NULL becomes null. Quoted SQL strings are always kept as strings; when a string could be misread by a YAML parser (for example 'yes', '0123', or 'null'), it is quoted in the output. Multi-line text is written with YAML block syntax.

Options

Choose two- or four-space indentation. Under the editors, a table preview of the first table lets you verify the parsed rows before you copy or download the .yaml file.

Supported SQL

The converter reads INSERT INTO, INSERT IGNORE, and REPLACE INTO statements with single or multi-row VALUES lists, in MySQL, PostgreSQL, SQLite, and SQL Server syntax. Column names come from the statement or a matching CREATE TABLE. Comments and non-data statements are skipped.

Why YAML for data?

Small lookup tables — countries, roles, feature flags, product categories — are often easier to maintain as YAML in a Git repository than as SQL. Reviewers see a clean diff when a value changes, and your application or seeder can load the file at startup.

Check the output with the YAML Validator, or convert it further with YAML to JSON. Other SQL exports: SQL to JSON and SQL to CSV. Starting from JSON? Use JSON to YAML.

Frequently Asked Questions

Values that YAML would otherwise read as a different type — such as '1', 'true', 'null', or text containing a colon followed by a space — are quoted so they stay strings when the file is loaded again.

A single table becomes a top-level list of mappings. When the SQL inserts into several tables, the YAML is a mapping keyed by table name, with each table's rows as a list underneath.

Yes. The list-of-mappings shape matches what fixture loaders such as Rails fixtures, Symfony/Doctrine fixture bundles, and many test frameworks expect, although you may need to add a top-level key they require.