How to Use the Json To Dbf: Step-by-Step Tutorial
The Json To Dbf Converter runs entirely in your browser โ your JSON file is never sent to any server, no account is required, and no data leaves your device. This tutorial walks through every step: loading a JSON array file, running the conversion, reading the stats panel, reviewing the inferred schema, and downloading the DBF. It also covers the most common problems you will encounter and how to resolve them.
Follow along with the tool open: Open the Json To Dbf Converter in a second tab, then work through each step below.
Open Json To Dbf Converter โTable of Contents
Step 1 โ Open the Tool
Navigate to /developer-tools/json-to-dbf/. The tool loads entirely in your browser. After the initial page load, converting a file makes no outbound network requests โ you can verify this in your browser's DevTools Network panel while the conversion runs.
The tool is accessible from the Developer Tools hub, the command palette (press Ctrl+K or โK and type "Json To Dbf"), or directly via the URL above.
Step 2 โ Prepare and Load Your JSON File
The converter accepts a JSON file where the top-level value is an array of flat objects. Every element of the array must be a plain object; nested arrays and nested objects as values will be serialized to a string before being written to the DBF Character field.
A minimal valid input looks like this:
[
{ "id": 1, "name": "Alice", "active": true },
{ "id": 2, "name": "Bob", "active": false },
{ "id": 3, "name": "Carol", "active": true }
]
Load the .json file using one of two methods:
- Drag and drop. Drag a
.jsonfile from your file manager, desktop, or Downloads folder and drop it anywhere on the blue-bordered drop zone. The zone highlights when a file is being dragged over it. You can also drop the file anywhere on the page โ a full-screen overlay appears to catch the drop. - Click to browse. Click the drop zone or the "browse" link inside it to open your operating system's file picker. Navigate to your
.jsonfile and select it.
Once the file is loaded, the filename appears in a bar below the drop zone. The drop zone itself hides to keep the interface clean. To replace the file, click the โ button in the filename bar โ this clears the loaded file and returns the drop zone so you can load a different one.
The tool accepts only .json files. If you drop a file with a different extension, a red error badge explains the problem. If your JSON is embedded in another file or a string in memory, copy it to a .json file first (pbpaste > data.json on macOS, or paste into a new file in any text editor).
Step 3 โ Click Convert to DBF
Once a file is loaded, click the Convert to DBF button. The conversion pipeline runs immediately in the browser:
- The file is parsed with
JSON.parse. If the file is not valid JSON or the root is not an array, an error is reported before any further processing. - Every key across every record is collected to build the union field set. For each field, every non-null value is scanned to infer the dBASE type: Logical (all booleans), Numeric (all numbers), or Character (anything else, or mixed types).
- A 32-byte file header and a 32-byte descriptor per field are assembled in a
Uint8Arraybuffer. A0x0Dterminator closes the header. - Each record is serialized as a fixed-length row: leading space byte (active), then each field value formatted for its type and padded to its declared length. A
0x1Aend-of-file byte closes the buffer.
For a JSON file with a few thousand records and 10โ20 fields, the conversion typically completes in well under a second. The button is disabled during processing to prevent accidental double-clicks.
Step 4 โ Read the Stats Panel
After a successful conversion, a green stats panel appears with the key numbers:
- Records. The total number of objects converted to DBF rows. Compare this against the length of your JSON array to confirm nothing was skipped.
- Fields. The number of columns in the DBF schema. This equals the size of the union of keys across all input objects.
- Record length. The fixed byte size of each DBF row โ the sum of all field lengths plus one byte for the active/deleted flag.
- Input size. The size of the original JSON input.
- Output size. The size of the generated DBF in memory. DBF is often smaller than the equivalent JSON because it strips all whitespace, field-name repetition, and JSON syntax overhead โ though Character fields are padded to the maximum value length, which can increase size for high-variance columns.
Step 5 โ Review the Inferred Schema Table
Below the stats panel, a schema table lists every field alongside its inferred DBF type, length, and decimal count. This is the single most important table to review before using the DBF.
The cases to look for:
- ID columns typed as Numeric. If your JSON has numeric IDs with leading zeros expressed as numbers (e.g.,
"id": 007), the leading zeros are lost during JSON parse before the converter ever sees them โ this is a JSON parser issue, not a DBF one. Quote those values in the source ("id": "007") to keep them as Character. - Date fields stored as Character. The converter does not emit DBF
D(Date) fields โ ISO date strings in JSON become Character fields. If your downstream system expects genuineDfields, post-process the DBF with a library that can rewrite the field descriptor. - Character field at the 254-byte limit. If any field value exceeds 254 bytes, the converter truncates to 254 and displays a warning. If the warning appears, review which field was affected โ a legitimate long-text column needs a different output format (see JSON to CSV).
- Field names truncated to 11 characters. DBF field names have an 11-byte cap. Long JSON keys are truncated and uppercased. If two keys share the same 11-character uppercase prefix, the last-written descriptor wins โ rename the source keys to avoid collision.
- Mixed-type columns promoted to Character. If a column has both numbers and strings across records (e.g., some rows have
"qty": 5and others have"qty": "N/A"), the converter falls back to Character with numbers written as their string representation. If you want the column Numeric, clean the JSON so every non-null value is a number.
If the schema table is empty, the JSON array was empty โ there were no records to build a schema from. Check your input file; a valid empty-array JSON ([]) parses successfully but produces a zero-record DBF with no fields, which most DBF readers will reject.
Step 6 โ Download the DBF
Click the green Download DBF button. The browser saves the file to your default downloads folder. The filename is constructed by replacing the .json extension of the input file with .dbf. For example, customers.json becomes customers.dbf.
After downloading, open the file and spot-check it before using it in production:
- Open the DBF in QGIS (attribute table), LibreOffice Calc (via the dBASE filter), or a DBF viewer utility. Confirm the field names and types match the schema table shown by the converter.
- Verify the record count matches the length of your source JSON array.
- For non-ASCII characters, write a sibling
.cpgfile containing the single lineUTF-8alongside the DBF. QGIS and modern FoxPro environments will read this and interpret the string bytes as UTF-8 rather than a default codepage. - Confirm that Numeric fields are right-aligned and Character fields are left-aligned โ this indicates the fixed-width padding was applied correctly.
- Pass the DBF through the DBF Validator to confirm the header, record count, and field definitions are well-formed.
Troubleshooting Common Problems
"Invalid JSON โ failed to parse." The file could not be parsed as JSON. Common causes: trailing commas (invalid in strict JSON), single-quoted strings (JSON requires double quotes), unescaped control characters, or BOM bytes at the start of the file. Run your JSON through the JSON Validator to find the exact syntax error and line number.
"Expected an array at the top level." The root of the JSON is an object or a scalar rather than an array. The converter requires an array of objects. If your data is an object with a single array property (e.g., {"records": [...]}), extract the inner array to a new file, or use jq '.records' data.json > flat.json to flatten.
Unexpected Character type for a numeric-looking column. This means at least one value in that column is not a JSON number. Check for null values (allowed โ these don't force Character), empty strings, or values wrapped in quotes ("42" is a string, 42 is a number). Clean the source JSON so every non-null value in the column is a bare number.
"Character value truncated โ exceeded 254 bytes." Classic DBF Character fields have a hard 254-byte cap. If your data has longer text values, either truncate at the source, emit a Memo field using a tool that supports .dbt, or use JSON to CSV instead โ CSV has no per-field byte limit.
DBF reader shows garbled non-ASCII characters. The converter writes strings as UTF-8 bytes, but older DBF readers default to a single-byte codepage (CP437 or Windows-1252). Create a sibling file with the same base name as your DBF and extension .cpg containing the single line UTF-8. Modern readers will pick up the codepage hint automatically.
QGIS shows only some rows in the attribute table. QGIS matches attribute rows to geometry rows by index, so a DBF intended to pair with a .shp file must have exactly the same record count as the shapefile. If the DBF row count differs from the shapefile, QGIS silently drops rows. Regenerate the DBF with a record count matching the geometry file.
Field names unexpectedly uppercase or truncated. DBF field names are 11 bytes, ASCII, and uppercase by convention. The converter applies both rules. Starting with DBF-friendly keys (CUST_ID, ORDER_NUM) in your source JSON avoids surprises in the output schema.
Worked Example
The following example shows a complete conversion using a small, representative JSON file.
Create the sample JSON file:
[
{ "ORDER_ID": 1001, "CUSTOMER": "Alice", "AMOUNT": 149.99, "SHIPPED": true },
{ "ORDER_ID": 1002, "CUSTOMER": "Bob", "AMOUNT": 32.50, "SHIPPED": true },
{ "ORDER_ID": 1003, "CUSTOMER": "Carol", "AMOUNT": 210.00, "SHIPPED": false }
]
Save this content as sample_orders.json on your machine. The field names are intentionally DBF-friendly (uppercase, โค11 bytes, underscore-separated) so the output schema matches what you wrote.
Convert using the tool:
- Open the Json To Dbf Converter.
- Drag
sample_orders.jsononto the drop zone, or click browse and select it. - The filename bar shows: ๐ sample_orders.json.
- Click Convert to DBF.
- The stats panel shows: Records: 3 ยท Fields: 4.
- The inferred schema table shows:
ORDER_ID(Numeric, length 4, decimals 0),CUSTOMER(Character, length 5),AMOUNT(Numeric, length 6, decimals 2),SHIPPED(Logical, length 1). - Click Download DBF. The file is saved as
sample_orders.dbf.
Verify the output: Open sample_orders.dbf in QGIS, LibreOffice Calc (with the dBASE filter), or the DBF Validator. You should see a 4-field, 3-record table. ORDER_ID values are right-aligned integers. CUSTOMER values are left-aligned and space-padded to 5 bytes. AMOUNT values are right-aligned with two decimal places. SHIPPED contains T or F.
If you want to see what happens with a mixed-type column, replace one AMOUNT value with the string "TBD" and re-convert. The field will be promoted to Character, with the numeric values written as their decimal string representations. This is the converter's fallback for inconsistent columns โ and a good example of why the schema table is worth reviewing before download.
For a deeper explanation of the DBF format, field type inference, and character encoding, see the Complete Guide to Json To Dbf.
