MySQL to JSON Converter

Transform MySQL database dumps into JSON arrays and objects with flexible formatting

MySQL Input

JSON Output

About MySQL to JSON Converter

Convert MySQL database dumps (CREATE TABLE and INSERT statements) to JSON (JavaScript Object Notation) format with flexible output structures. Perfect for web development, APIs, and data interchange.

Key Features

  • Object Format: Convert to array of objects using column names as keys
  • Array Format: Convert to nested arrays for simple data structures
  • Pretty Printing: Format JSON with indentation for readability
  • Compact Output: Minified JSON for production use
  • Column Detection: Automatically use CREATE TABLE columns as object keys
  • File Download: Save as .json file
  • Instant Preview: Real-time conversion as you type

How to Use

  1. Input MySQL Data: Paste your MySQL dump or upload a .sql file
  2. Configure Options: Choose column treatment and formatting
  3. Review Output: The JSON updates automatically
  4. Copy or Download: Use the JSON in your application

Output Formats

  • Array of Objects: Each row becomes an object with column name keys
  • Array of Arrays: Simple nested array structure
  • Pretty Print: Indented and formatted for readability
  • Compact: Single-line minified output

Example Conversion

MySQL Input:

CREATE TABLE employees (
  id INT PRIMARY KEY,
  name VARCHAR(100),
  age INT,
  department VARCHAR(50)
);

INSERT INTO employees VALUES (1, 'John Doe', 28, 'Engineering');
INSERT INTO employees VALUES (2, 'Jane Smith', 34, 'Marketing');

JSON Output (Array of Objects):

[
  {
    "id": "1",
    "name": "John Doe",
    "age": "28",
    "department": "Engineering"
  },
  {
    "id": "2",
    "name": "Jane Smith",
    "age": "34",
    "department": "Marketing"
  }
]

JSON Output (Array of Arrays):

[
  ["id", "name", "age", "department"],
  ["1", "John Doe", "28", "Engineering"],
  ["2", "Jane Smith", "34", "Marketing"]
]

Common Use Cases

  • Web Development: Convert database data for JavaScript applications
  • REST APIs: Prepare MySQL data for API responses
  • Data Migration: Export MySQL data to NoSQL databases
  • Configuration: Create JSON config files from database tables
  • NoSQL Databases: Import data into MongoDB, CouchDB, etc.
  • Node.js: Use MySQL data in Node.js applications
  • Data Analysis: Import into JavaScript data visualization libraries

JSON Standards

This converter generates valid JSON according to RFC 8259:

  • Proper string escaping and encoding
  • Valid object and array structures
  • UTF-8 character encoding
  • Standard formatting and indentation

Integration Examples

JavaScript:

const data = [
  {"id": "1", "name": "John Doe", "age": "28"},
  {"id": "2", "name": "Jane Smith", "age": "34"}
];

// Use in your application
data.forEach(person => {
  console.log(person.name, person.age);
});

Python:

import json

with open('output.json', 'r') as f:
    data = json.load(f)
    
for person in data:
    print(person['name'], person['age'])

Supported MySQL Syntax

  • CREATE TABLE: Extracts column names from table definitions
  • INSERT INTO: Parses VALUES clauses with quoted strings
  • Column Lists: Supports INSERT INTO table (col1, col2) VALUES format
  • Quoted Values: Handles single and double quotes properly
  • Escaped Quotes: Processes escaped quotes in string values

Tips for Best Results

  • Include CREATE TABLE for automatic column name detection
  • Enable pretty print for development and debugging
  • Use compact format for production and APIs
  • Validate JSON output with online validators if needed
  • Consider data types when using in typed languages
  • Use object format for self-describing data

Privacy & Security

All conversions happen locally in your browser. Your MySQL data is never uploaded to any server, ensuring complete privacy and security.