Markdown to SQL Converter
Transform Markdown tables into SQL statements with support for MySQL, PostgreSQL, SQLite, and SQL Server
Markdown Input
SQL Output
About Markdown to SQL Converter
Convert Markdown tables to SQL CREATE TABLE and INSERT statements with support for multiple database dialects including MySQL, PostgreSQL, SQLite, and SQL Server. Features automatic type detection, proper identifier quoting, and NULL handling.
Key Features
- Multi-Dialect Support: MySQL, PostgreSQL, SQLite, and SQL Server
- CREATE TABLE: Generate table schema with proper column definitions
- INSERT Statements: Generate data insertion statements
- Type Detection: Automatically detect INTEGER, DECIMAL, DATE, VARCHAR, TEXT
- Identifier Quoting: Proper quoting with `, ", or [] based on dialect
- String Escaping: Proper escaping of single quotes and special characters
- NULL Handling: Empty cells converted to NULL values
- Custom Table Name: Specify your own table name
- File Upload: Upload .md files directly
- Instant Preview: Real-time conversion as you type
- Copy & Download: Easy export as .sql file
How to Use
- Input Markdown Table: Paste your Markdown table or upload a .md file
- Configure Table Name: Set the desired table name
- Select SQL Dialect: Choose your database system
- Toggle Options: Enable/disable CREATE TABLE, INSERT statements, and type detection
- Review Output: The SQL statements update automatically
- Export: Copy to clipboard or download as .sql file
SQL Dialects
- MySQL: Uses backticks (`) for identifiers, supports TINYINT, SMALLINT, INT, BIGINT
- PostgreSQL: Uses double quotes (") for identifiers, NUMERIC type for decimals
- SQLite: Uses double quotes ("), simplified type system
- SQL Server: Uses brackets ([]) for identifiers, NVARCHAR(MAX) for long text
Example Conversion
Markdown Input:
| Name | Age | City | Department | |------|-----|------|------------| | John Doe | 28 | New York | Engineering | | Jane Smith | 34 | London | Marketing |
MySQL Output:
-- Create table
CREATE TABLE `data_table` (
`name` VARCHAR(50),
`age` INTEGER,
`city` VARCHAR(50),
`department` VARCHAR(50)
);
-- Insert data
INSERT INTO `data_table` (`name`, `age`, `city`, `department`) VALUES ('John Doe', 28, 'New York', 'Engineering');
INSERT INTO `data_table` (`name`, `age`, `city`, `department`) VALUES ('Jane Smith', 34, 'London', 'Marketing'); Common Use Cases
- Database Migration: Import data from Markdown documentation into databases
- Test Data: Generate SQL test data for development and testing
- Data Seeding: Create seed data scripts for application initialization
- Documentation: Convert documented data into executable SQL
- Prototyping: Quickly create database schemas from table mockups
- Data Transfer: Move data between different database systems
- Learning SQL: Practice SQL with real-world data examples
Type Detection
When auto-detect is enabled, the converter analyzes column data:
- TINYINT: Integers 0-127
- SMALLINT: Integers 128-32,767
- INTEGER/INT: Integers 32,768-2,147,483,647
- BIGINT: Integers larger than 2,147,483,647
- DECIMAL/NUMERIC: Decimal numbers (10,2 precision)
- DATE/DATETIME: Values matching YYYY-MM-DD format
- VARCHAR(50): Text up to 50 characters
- VARCHAR(255): Text up to 255 characters
- TEXT/NVARCHAR(MAX): Text longer than 255 characters
Identifier Quoting
Each dialect uses different quoting for identifiers:
- MySQL: Backticks: `table_name`, `column_name`
- PostgreSQL: Double quotes: "table_name", "column_name"
- SQLite: Double quotes: "table_name", "column_name"
- SQL Server: Brackets: [table_name], [column_name]
String Escaping
Single quotes in data are properly escaped:
- O'Brien → 'O''Brien'
- It's → 'It''s'
- Empty cells → NULL
Column Name Sanitization
Column names are automatically sanitized:
- Converted to lowercase
- Special characters replaced with underscores
- Numbers at start prefixed with underscore
- Multiple underscores collapsed to single
- Example: "First Name" → "first_name"
MySQL Specific Features
- Backtick identifier quoting
- TINYINT, SMALLINT, INT, BIGINT types
- DECIMAL(10,2) for decimal numbers
- TEXT type for long strings
- Compatible with MySQL 5.7+ and MariaDB
PostgreSQL Specific Features
- Double quote identifier quoting
- INTEGER, BIGINT types
- NUMERIC(10,2) for decimal numbers
- TEXT type for long strings
- Compatible with PostgreSQL 9.6+
SQLite Specific Features
- Double quote identifier quoting
- Simplified type system
- INTEGER, DECIMAL types
- TEXT type for strings
- Compatible with SQLite 3+
SQL Server Specific Features
- Bracket identifier quoting
- TINYINT, SMALLINT, INT, BIGINT types
- DECIMAL(10,2) for decimal numbers
- NVARCHAR(MAX) for long Unicode strings
- DATETIME for date values
- Compatible with SQL Server 2012+
Best Practices
- Enable auto-detect types for optimal column definitions
- Use meaningful table names that follow naming conventions
- Review generated SQL before executing in production
- Test with sample data first
- Consider adding primary keys and indexes manually
- Add constraints (NOT NULL, UNIQUE) as needed
- Use transactions for large INSERT operations
Advanced Usage
Adding Primary Key:
CREATE TABLE `users` ( `id` INTEGER PRIMARY KEY AUTO_INCREMENT, `name` VARCHAR(50), `age` INTEGER );
Adding Constraints:
CREATE TABLE `users` ( `name` VARCHAR(50) NOT NULL, `age` INTEGER CHECK (age >= 0), `email` VARCHAR(255) UNIQUE );
Performance Tips
- For large datasets, use bulk INSERT or LOAD DATA INFILE
- Wrap multiple INSERTs in a transaction
- Consider using prepared statements for repeated inserts
- Add indexes after data insertion for better performance
- Use appropriate data types to save storage space
Tips for Best Results
- Choose the correct SQL dialect for your database
- Enable type detection for accurate column types
- Use descriptive column names in your Markdown table
- Ensure data consistency within columns
- Test generated SQL in a development environment first
- Consider adding indexes and constraints after import
- Use transactions for data integrity
Privacy & Security
All conversions happen locally in your browser. Your Markdown data is never uploaded to any server, ensuring complete privacy and security.
