Whilst browsing the FileMaker forums, we came across a question about parsing CSV data. This caught our interest and made us ask a simple question:
Could we take some CSV data and transform it into a valid JSON object?
The answer was yes — and with that, we present fm-csv2json.
What It Does
fm-csv2json is a FileMaker script which, when passed a valid CSV string, converts it into a JSON object. This makes it straightforward to work with CSV data using FileMaker's built-in JSON functions, introduced in FileMaker 16.
How It Works
The script accepts a CSV string as its input parameter. It begins by extracting the first row of the CSV data, which it treats as the header row containing the field names. These headers become the keys in the resulting JSON objects.
Once the headers have been parsed, the script iterates through each subsequent row of the CSV data. For every row, it builds a JSON object by pairing each header with the corresponding value from that row. Each of these objects is then appended to a JSON array, resulting in a complete array of objects that faithfully represents the original tabular data.
The script handles standard CSV conventions, including comma-delimited values and quoted fields. The output is a valid JSON array that can be immediately processed using FileMaker's native JSON functions such as JSONGetElement, JSONListKeys, and JSONListValues.
Example
Given the following CSV input:
Name,Email,Role
Steven McGill,steven@example.com,Developer
Jane Smith,jane@example.com,Designer
Bob Wilson,bob@example.com,Manager
fm-csv2json produces the following JSON output:
[
{
"Name": "Steven McGill",
"Email": "steven@example.com",
"Role": "Developer"
},
{
"Name": "Jane Smith",
"Email": "jane@example.com",
"Role": "Designer"
},
{
"Name": "Bob Wilson",
"Email": "bob@example.com",
"Role": "Manager"
}
]
Installation
Getting started with fm-csv2json is straightforward. First, download the script from the GitHub repository. Once downloaded, import the script into your FileMaker solution using the Import Scripts option within FileMaker's script workspace.
To use the script, simply call it with a valid CSV string as the script parameter. The script will return the resulting JSON array, which you can then capture using Get ( ScriptResult ) and process as needed within your solution.
Use Cases
There are numerous scenarios where converting CSV to JSON within FileMaker proves invaluable:
- Importing data from external systems — Many third-party applications export data in CSV format. With fm-csv2json, you can convert these exports into JSON and use FileMaker's JSON functions to selectively import the data you need.
- Processing CSV exports from other software — Whether it's accounting software, CRM platforms, or reporting tools, CSV remains one of the most common export formats. This script bridges the gap between CSV and FileMaker's modern JSON capabilities.
- Building ETL pipelines in FileMaker — For developers constructing extract, transform, and load workflows, fm-csv2json provides a clean transformation step that converts raw CSV data into a structured format that is far easier to manipulate programmatically.
- Migrating data from spreadsheets — When migrating data from Excel or Google Sheets, saving as CSV and then converting to JSON with this script offers a reliable and repeatable import pathway.
Requirements
fm-csv2json requires FileMaker Pro 16 or later. This is because the script relies on the native JSON functions — JSONSetElement, JSONGetElement, and related functions — that were first introduced in FileMaker 16. The script runs entirely within FileMaker's native scripting engine, so no plugins or external dependencies are required. It is also fully compatible with FileMaker Server and FileMaker Cloud for server-side execution.
Download
The script is available to download free of charge on GitHub.
Related Tool
We also built a similar parser that converts XML into JSON. Check out fm-xml2json.