JSON.ToCSV
----------

Converts JSON to CSV.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [JSON](component_JSON.md) | [15.2](newinversion152.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "JSON.ToCSV"; JSON { ; Flags; rowSeparator; colSeparator } ) 

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

### 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](JSONQuery.md), [JSON.Search](JSONSearch.md) or one of the other [JSON](component_JSON.md) functions.  
  
Please use [Text.WriteTextFile](TextWriteTextFile.md) 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\\"}  
\]")  
<small>  
Example result:   
name;state  
Seattle;WA  
New York;NY  
Bellevue;WA  
Olympia;WA</small>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; ¶; ",")  
<small>  
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</small>Convert to CSV with arrays:

 MBS ( "JSON.ToCSV"; "\[  
 \[\\"name\\", \\"state\\"\],  
 \[\\"Seattle\\", \\"WA\\"\],  
 \[\\"New York\\", \\"NY\\"\],  
 \[\\"Bellevue\\", \\"WA\\"\],  
 \[\\"Olympia\\", \\"WA\\"\]  
\]")  
<small>  
Example result:   
name;state  
Seattle;WA  
New York;NY  
Bellevue;WA  
Olympia;WA</small>### See also

- [JSON.Query](JSONQuery.md)
- [JSON.Search](JSONSearch.md)
- [Text.WriteTextFile](TextWriteTextFile.md)

### Release notes

- **Version 15.4**
    - Improved [JSON.ToCSV](https://www.mbsplugins.eu/JSONToCSV.shtml) to take an JSON array of arrays in addition to arrays of objects.
- **Version 15.2**
    - Added [JSON.ToCSV](https://www.mbsplugins.eu/JSONToCSV.shtml) function.

### Blog Entries

- [MBS FileMaker Plugin, version 15.4pr1](https://www.mbsplugins.de/archive/2025-08-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [News in MBS FileMaker Plugin 15.2](https://www.mbsplugins.de/archive/2025-05-13/News_in_MBS_FileMaker_Plugin_1/monkeybreadsoftware_blog_filemaker)
- [Neues MBS Plugin 15.2 für Claris FileMaker](https://www.mbsplugins.de/archive/2025-05-06/Neues_MBS_Plugin_152_für_Clar/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin 15.2 for Claris FileMaker](https://www.mbsplugins.de/archive/2025-05-06/MBS_Plugin_152_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 15.2pr6](https://www.mbsplugins.de/archive/2025-04-25/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 24th April 2025 , last changed 19th July 2025

  
[JSON.Text](JSONText.md) - [JSON.ToHTML](JSONToHTML.md)

[HTML Version](JSONToCSV.shtml)