I Help You

SQL → PHP Array Converter

Convert MySQL CLI output (+--+ borders), tab-separated, or pipe-separated SQL results into a PHP associative array ready to paste into code. Free, and it runs entirely in your browser — nothing you enter is uploaded.

How to use the SQL → PHP Array Converter

1. Copy SQL result output from MySQL CLI (including the +---+ border lines), or tab-separated / pipe-separated output.

2. Paste it here and click Convert. Numbers are auto-typed; strings are single-quoted; NULL becomes null.

What is it?

This tool converts MySQL CLI table output or raw SQL result data into a PHP associative array — ready to paste into your PHP code, Laravel seeder, or test fixture. Each row becomes an associative array with column names as keys.

Numbers are kept as integers or floats (unquoted). Strings are wrapped in single quotes with backslashes and single quotes properly escaped. NULL values in the SQL output become PHP null.

Example

MySQL CLI output
+----+------+-----+
| id | name | age |
+----+------+-----+
|  1 | John |  30 |
|  2 | Mary |  25 |
+----+------+-----+
↓
PHP array
$results = [
  [
    'id' => 1,
    'name' => 'John',
    'age' => 30
  ],
  [
    'id' => 2,
    'name' => 'Mary',
    'age' => 25
  ]
];

Benefits

Generate INSERT and CREATE TABLE statements instantly

Convert JSON, CSV, or a field list into ready-to-run SQL in seconds — no manual quoting, no counting columns, no copy-paste errors from spreadsheet data.

Build SELECT queries without memorising syntax

The visual query builder constructs WHERE conditions, ORDER BY, LIMIT, and DISTINCT clauses interactively — useful for anyone who writes SQL occasionally rather than daily.

Migrate between MongoDB and relational databases

Convert MongoDB find, insert, update, and delete operations directly to SQL equivalents — speed up data migration planning or schema exploration.

All your data stays in the browser

No SQL query, schema definition, or database content is ever uploaded to a server. Everything runs entirely client-side, making these tools safe to use with sensitive data.

Frequently asked questions

Can I use this with PDO or MySQLi fetch results?

This tool converts raw CLI table output. If you need a PHP array from PDO, use $stmt->fetchAll(PDO::FETCH_ASSOC) directly in your code.

What if a value contains a single quote?

Single quotes in values are automatically escaped as \' in the PHP output.