SQL to Firebase Converter

Transform SQL database dumps into Firebase Realtime Database format

About SQL to Firebase Converter

Convert SQL database dumps (CREATE TABLE and INSERT statements) to Firebase Realtime Database JSON structure. Perfect for migrating SQL data to Firebase or creating test data for Firebase applications.

Key Features

  • Automatic Parsing: Extracts table structure and data from SQL dumps
  • Type Conversion: Converts SQL data types to appropriate JSON types (numbers, booleans, strings, null)
  • Flexible Keys: Choose between auto-generated keys or use a specific column as the key
  • Firebase Compatible: Generates JSON structure ready for Firebase import
  • Key Sanitization: Removes Firebase-restricted characters (., #, $, [, ]) from keys
  • File Upload: Upload .sql files directly

How to Use

  1. Input SQL Data: Paste your SQL CREATE TABLE and INSERT statements or upload a .sql file
  2. Configure Keys: Choose auto-generated keys or specify a column to use as Firebase keys
  3. Review Output: The Firebase JSON generates automatically
  4. Copy or Download: Use the Copy or Download button to save your Firebase data

Key Options

  • Auto-Generated Keys: Creates keys like item_0, item_1, item_2... (default)
  • Custom Key Field: Use a specific column (e.g., "id") as the Firebase key

Example Conversion

SQL Input:

CREATE TABLE employees (
  id INT PRIMARY KEY,
  name VARCHAR(100),
  age INT,
  salary DECIMAL(10,2)
);

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

Firebase JSON Output (Auto Keys):

{
  "item_0": {
    "id": 1,
    "name": "John Doe",
    "age": 28,
    "salary": 75000
  },
  "item_1": {
    "id": 2,
    "name": "Jane Smith",
    "age": 34,
    "salary": 82000.5
  }
}

Firebase JSON Output (Using 'id' as key):

{
  "1": {
    "id": 1,
    "name": "John Doe",
    "age": 28,
    "salary": 75000
  },
  "2": {
    "id": 2,
    "name": "Jane Smith",
    "age": 34,
    "salary": 82000.5
  }
}

Type Conversion

  • Numbers: INT, BIGINT, DECIMAL, FLOAT, DOUBLE → JSON numbers
  • Booleans: BOOLEAN, true/false → JSON booleans
  • Strings: VARCHAR, CHAR, TEXT → JSON strings
  • NULL: NULL or empty values → JSON null

Firebase Key Restrictions

Firebase keys cannot contain certain characters. This tool automatically sanitizes keys by replacing the following characters with underscores:

  • . (period)
  • # (hash)
  • $ (dollar sign)
  • [ (left bracket)
  • ] (right bracket)

Common Use Cases

  • Database Migration: Migrate SQL data to Firebase Realtime Database
  • Test Data: Create Firebase test data from SQL dumps
  • Prototyping: Quickly populate Firebase with existing SQL data
  • Data Backup: Export SQL data in Firebase-compatible format
  • Cross-Platform: Share data between SQL and Firebase applications
  • Development: Seed Firebase development databases from SQL

Importing to Firebase

To import the generated JSON to Firebase Realtime Database:

  1. Open Firebase Console
  2. Navigate to Realtime Database
  3. Click the three-dot menu (⋮) and select "Import JSON"
  4. Upload the downloaded JSON file

Frequently Asked Questions

  • Q: Is this JSON for Realtime Database or Firestore? A: The structure is tailored for Firebase Realtime Database imports. Firestore uses a different format and API.
  • Q: How are numeric and boolean values handled? A: The tool converts numeric-looking strings to numbers and "true"/"false" to booleans so that data types in Firebase are correct.
  • Q: What if my chosen key field is not unique? A: Duplicate keys will overwrite previous entries in Firebase. Ensure the key column you pick has unique values.
  • Q: Can I nest data under a parent path? A: Yes. After import, you can move or nest the generated JSON under any path in the Realtime Database UI or via rules.
  • Q: Does this configure Firebase security rules? A: No. The tool only prepares JSON data. You should configure Firebase rules separately in the console.

Privacy & Security

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