How to Export MariaDB to JSON, Step by Step
Step 1: Connect to MariaDB
Host, port (3306 by default), account and database, then connect. The Test button reports the server version, so a grant or firewall problem shows up before the export.
Step 2: Choose the table or the query
A single table, every table in a schema, or a SELECT pasted straight in - the column list comes from what you pick and stays editable.
Key Features
DBToFile connects to MariaDB the way any client does, so nothing has to be installed or granted on the server side - and every export is a saved task rather than a set of options you rebuild each time:
- Table, query, or every table in a schema - a batch run writes one file per table, named after the table.
- Column list and order are part of the task, so the output does not drift when the table grows.
- Types are honoured while writing: dates stay dates, numbers are not quoted, NULL keeps its own marker.
- The file is written where you are, not on the database host - no
secure_file_privpath to chase. - Saved and scheduled: the same task runs from Task Scheduler,
cronorlaunchd. - Local: the rows travel between your machine and the database, nowhere else.
What a MariaDB column becomes in the JSON
A JSON is text, so the interesting part is where each MariaDB type loses something on the way out.
| In MariaDB | In the JSON |
|---|---|
| INT, BIGINT, DECIMAL | a JSON number - watch BIGINT UNSIGNED beyond 2^53 and DECIMAL read by a float parser |
| VARCHAR, TEXT | a JSON string, escaped |
| DATETIME, TIMESTAMP | a string in ISO form; JSON has no date type |
| DATE | a string |
| NULL | the JSON literal null - the one format where NULL is not lost |
| JSON column | kept as nested JSON when the document shape allows it, otherwise as a string |
| BLOB, VARBINARY | not text - export HEX(col) or the tool writes the raw bytes into the string |
| ENUM / SET | the label |
One array, one object per line, or JSON_OBJECT() in SQL?
Two shapes live behind this one page: one array holding every row as an object (what a web API expects), or one object per line - JSONL/NDJSON, which appends and streams. The choice is a setting, not a different tool, and it is the only real decision in a JSON export.
MariaDB can also build JSON in SQL with JSON_OBJECT() and JSON_ARRAYAGG(), and that is the right tool for a report. What it does not give you is a file: the aggregate is limited by max_allowed_packet and the result still has to be fetched. A client export streams instead.
MariaDB to JSON — Quick Facts
- Shape
- array of objects, or one object per row (JSONL)
- Numbers
- BIGINT beyond 2^53 and DECIMAL lose precision in float parsers
- Dates
- strings - JSON has no date type
- NULL
- the literal null
- Default port
- 3306
- Server-side alternative
JSON_OBJECT/JSON_ARRAYAGG, limited bymax_allowed_packet
Common pitfalls when exporting MariaDB to JSON
- A JSON column exported as a string arrives double-encoded:
"{\"a\":1}"instead of an object. - BIGINT ids beyond 2^53 change value when a JavaScript or Python float parser reads the file.
- TIMESTAMP written in the session zone looks like a different instant to a reader that assumes UTC.
- One huge array is not streamable: a consumer has to parse the whole file before it sees the first row - JSONL avoids that.
- Invalid UTF-8 in a TEXT column makes the document unparseable; the writer has to know the client charset.
Which searches land here
This page exports MariaDB → JSON. The neighbouring searches below mean a different direction, a different format or a different target engine:
| What you searched | Meaning | Page |
|---|---|---|
| mariadb export to json, export table to json, mariadb export json | read MariaDB, write a JSON file | this page |
| json to mariadb, import json into mariadb | the reverse | JSON to MariaDB |
| mariadb to csv, mariadb to tsv, mariadb to txt, mariadb to xml, mariadb to sql, mariadb to html | a different output format from the same connection | CSV / TSV / TXT / XML / SQL / HTML |
| mariadb to sqlite, mariadb to sql server, mariadb to mysql | another database engine as the target, not a file | MariaDB to SQLite / SQL Server / MySQL |
| mariadb export database to sql file, mysqldump single table | a script of rows, or a schema dump | this page (MariaDB to SQL) |
The export itself is the same job in both directions - it is the reader and the target system that decide which side of the arrow a query belongs to.
Verify three things before you hand the file over
- Row count: compare
SELECT COUNT(*)with the records the task reports - a short count means a skipped or rejected row. - First and last row: check the header and the very last field, which is where a quoting or newline problem shows up first.
- Types in the file: a date should not be quoted as text, a number should not carry a thousands separator.
Frequently Asked Questions
Download Withdata DBToFile Now
Start exporting MariaDB to JSON in seconds - free trial for all platforms.
$75 one-time · volume discounts to $55 · 30-day money-back · pricing & licence terms

