ToolLineup

SQL to YAML Converter

This SQL to YAML converter reads INSERT … VALUES statements and writes each row as a YAML mapping in a list, keyed by the column names from the statement. That is exactly the shape test fixtures, seed files and configuration samples take, so a dump from a real database becomes usable test data without hand-editing. Types survive the trip: numbers stay unquoted, TRUE and FALSE become YAML booleans and NULL becomes an empty value rather than the string "NULL". Several INSERTs into the same table are merged, and the parsing handles escaped quotes and commas inside string literals correctly.

How it works

Each inserted row becomes one YAML mapping in a list, keyed by the column names in the statement. The result is ready to paste into a fixture, a seed file or a test.

Types are preserved from the SQL literals, so numbers are unquoted, TRUE and FALSE become booleans and NULL becomes an empty YAML value.

The conversion runs entirely in your browser — nothing you paste or upload is sent to a server.

SQL input
Paste INSERT statements or upload a .sql dump…
YAML output

How to convert SQL to YAML

  1. Paste your INSERT statements into the input on the left, or upload a .sql dump.
  2. If the dump covers several tables, pick the one you want with the table number box.
  3. Copy the YAML list, or download it as a .yaml file.

Real data makes better fixtures

Test fixtures in most frameworks are YAML lists of mappings — the same shape as a table of rows. Hand-written fixtures tend to be too tidy: every name is short, no field is null, no string contains an apostrophe or a newline. Converting a real dump gives you data with the awkward cases still in it, which is exactly what a test suite should be exercising.

Types are preserved

An unquoted 42 in the SQL becomes an unquoted 42 in the YAML, TRUE becomes a boolean and NULL becomes an empty value. The fixture therefore loads with the same types the database column had, instead of turning every field into a string.

Values YAML would misread

YAML is unusually eager about interpreting bare text. Values like yes, no, on, 2026-08-18 and 1.20 would be read back as a boolean, a date or a number with the trailing zero lost. Any string that would be misread is quoted automatically, so it loads back as the string it started as.

Common use cases

  • Building fixtures for a test suite from a production snapshot.
  • Producing seed data for a local development database.
  • Turning a lookup table into a configuration file.

Frequently asked questions

How do I convert SQL to YAML?

Paste your INSERT statements into the left panel or upload a .sql file. The YAML list appears on the right, ready to copy or download.

Why convert SQL to YAML?

Test fixtures and seed files in most frameworks are YAML lists of mappings, which is the same shape as a table of rows. Converting a real dump gives you realistic test data without typing it out.

Are types preserved?

Yes. Numbers stay unquoted, TRUE and FALSE become booleans and NULL becomes an empty value, so the fixture loads with the same types the database had.

What if a value needs quoting in YAML?

It is quoted automatically. Values that would otherwise be read as a number, a boolean, a date or a null are given quotes so they load back as strings.

Can it handle a dump with several tables?

Yes. Each table is collected separately and the table number box steps through them.

Is my dump sent anywhere?

No. Everything is parsed in your browser.

Related tools