Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

JSON.ToCSV

Converts JSON to CSV.

Component Version macOS Windows Linux Server iOS SDK
JSON 15.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "JSON.ToCSV"; JSON { ; Flags; rowSeparator; colSeparator } )   More

Parameters

Parameter Description Example Flags
JSON A JSON text or reference. "[
{\"name\": \"Seattle\", \"state\": \"WA\"},
{\"name\": \"New York\", \"state\": \"NY\"}
]"
Flags Various flags.
1: Pass 1 to put all text values in quotes.
2: Skip column names in first row.
0 Optional
rowSeparator The row separator.
Default is CR.
Can be more than one character.
Char(13) Optional
colSeparator The column separator.
Default is semicolon.
Can be more than one character.
";" Optional

Result

Returns text or error.

Description

Converts JSON to CSV.
You may prepare the JSON to be an array of objects using JSON.Query, JSON.Search or one of the other JSON functions.

Please use Text.WriteTextFile to write to text file if you need CSV export.

Examples

Convert to CSV:

MBS( "JSON.ToCSV"; "[
  {\"name\": \"Seattle\", \"state\": \"WA\"},
  {\"name\": \"New York\", \"state\": \"NY\"},
  {\"name\": \"Bellevue\", \"state\": \"WA\"},
  {\"name\": \"Olympia\", \"state\": \"WA\"}
]")

Example result:
name;state
Seattle;WA
New York;NY
Bellevue;WA
Olympia;WA

Convert to CSV with comma:

MBS( "JSON.ToCSV"; "[
    {
        \"Author\": \"Haruki Murakami\",
        \"category\": \"fiction\",
        \"price\": 20.0,
        \"title\": \"A Wild Sheep Chase\"
    },
    {
        \"Author\": \"Sergei Lukyanenko\",
        \"category\": \"fiction\",
        \"price\": 23.58,
        \"title\": \"The Night Watch\"
    },
    {
        \"Author\": \"Graham Greene\",
        \"category\": \"fiction\",
        \"price\": 21.99,
        \"title\": \"The Comedians\"
    },
    {
        \"Author\": \"Phillips, David Atlee\",
        \"category\": \"memoir\",
        \"title\": \"The Night Watch\"
    }
]"; 0; ¶; ",")

Example result:
Author,category,price,title
Haruki Murakami,fiction,20.0,A Wild Sheep Chase
Sergei Lukyanenko,fiction,23.58,The Night Watch
Graham Greene,fiction,21.99,The Comedians
"Phillips, David Atlee",memoir,,The Night Watch

See also

Release notes

Blog Entries

This function checks for a license.

Created 24th April 2025, last changed 25th April 2025


JSON.Text - JSON.ToHTML