SQL to YAML Converter – Convert SQL Queries to YAML Online Free
Convert SQL query results or database tables to YAML format online free. Export MySQL, PostgreSQL, SQLite to YAML instantly.
Converted results will appear here
Convert SQL queries to YAML online free. Export MySQL, PostgreSQL, SQLite to YAML. Perfect for Kubernetes and Ansible.
Convert SQL to YAML – Complete Guide
Transform your SQL query results into YAML – the human-friendly data serialization standard for configuration files, Kubernetes, Ansible, and CI/CD pipelines. Our SQL to YAML Converter supports all major SQL dialects.
How It Works
You provide a SQL SELECT query. Our engine executes it and converts each row into a YAML map (object). The output is a YAML list (sequence) of these maps, or optionally a single document with a root key.
Supported SQL Dialects
| Database | Example Query |
|---|---|
| MySQL | SELECT app_name, version, replicas FROM deployments |
| PostgreSQL | SELECT * FROM config_items |
| SQLite | SELECT env, value FROM settings |
Code Example & Output
-- Input SQL (MySQL)
SELECT id, service, port FROM microservices WHERE active = 1;
-- Output YAML (list of maps)
- id: 1
service: auth-api
port: 8080
- id: 2
service: payment-api
port: 8081
-- Output YAML (with root key)
data:
- id: 1
service: auth-api
port: 8080
- id: 2
service: payment-api
port: 8081
-- Output YAML (single document, multi-line strings)
- description: |
This is a long
multi-line description
enabled: true
Advanced Options
- Root key: wrap list under a key (e.g., "data")
- NULL handling: null, empty string, or omit
- Indentation: 2 spaces (default), 4 spaces, or tabs
- Multi-line strings: literal style (|) or folded (>)
- Boolean format: true/false or yes/no
- Document separator: --- between documents for batch mode
Use Cases
- Generate Kubernetes ConfigMaps and Secrets from SQL tables
- Create Ansible inventory or variable files from database
- Export configuration data for Docker Compose or Helm values
- Produce YAML for GitHub Actions or GitLab CI workflows
- Human-readable data dumps for documentation
YAML is ideal for configuration because it's less noisy than JSON or XML. Our converter automatically uses block scalars for multi-line text and properly escapes special characters. Numbers, booleans, and nulls are correctly typed.
For large result sets, the tool streams YAML output to avoid memory issues. Batch mode allows you to convert multiple SELECT queries into a single YAML file with --- separators.
No registration, no watermarks, completely free.
Frequently Asked Questions
Everything you need to know about this tool