JSON.Colorize
-------------

Formats a JSON string with color.

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

MBS( "JSON.Colorize"; JSON { ; DarkMode } ) 

**MBS**( **"JSON.Colorize";** /\* Formats a JSON string with color. \*/  
**$JSON**; /\* A JSON text.e.g. {"key":"value"} \*/   
**$DarkMode**) /\* Optional; Whether to swap colors to use white for text color.  
Pass 1 for dark mode and 0 for light mode.  
Default is 0 for light mode.e.g. 0 \*/ 

(old name: JSON.Colourise)

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| JSON | A JSON text. | {"key":"value"} |  |
| DarkMode | Whether to swap colors to use white for text color.   Pass 1 for dark mode and 0 for light mode.   Default is 0 for light mode. | 0 | Optional      Added in version **12.1**. |

### Result

Returns formatted text or error.

### Description

Formats a JSON string with color.  
This colorizes an existing JSON text to show to user, but does not check syntax.  
Keys get blue, text value purple, numbers and others orange and brackets black.  
  
Text is returned only with colors. You can apply text font and font size with normal FileMaker functions.  
Processing time is linear to length, so should be faster than custom functions.  
  
Applying text styles takes time. You may consider to skip this if your JSON is e.g. bigger than a million characters to improve performance of your scripts.  
  
Colors used for JSON and XML colorization:  
  
| What | Light | Dark |
|---|---|---|
| Brackets and commas | \#000000 Black | \#FFFFFF White |
| Object Keys | \#3C4BEB Blue | \#6473FF Blue |
| Text Values | \#AC2C6A Purple | \#D65492 Purple |
| Numbers | \#AF6527 Orange | \#D78D4F Orange |

### Examples

Colorize a field:

 Set Field \[ Data::JSON ; MBS ("JSON.Colorize"; Data::JSON ) \]  
Colorize in Auto-Enter calculation:

 MBS ("JSON.Colorize"; self)  
  
// put this calculation into a field, so the field gets colorized whenever the field is changed and the record gets commited.  
Colorize leaves escapes in place:

 MBS ("JSON.Colorize"; "\[\\"Test\\",\\"🍎\\",\\"Escaped \\uD83C\\uDF4E\\"\]")  
<small>  
Example result:   
\["Test" ,"🍎" ,"Escaped \\uD83C\\uDF4E" \] </small>Colorize and format in Auto-Enter calculation:

 Let ( \[  
jsonFormatted = MBS ("[JSON.Format](JSONFormat.md)"; Self);  
jsonFormatFailed = MBS ("IsError");  
jsonText = If(jsonFormatFailed; Self; jsonFormatted);  
result = MBS ("JSON.Colorize"; jsonText)  
\]; result )  
  
// put this calculation into a field, so the field gets formated and colorized whenever the field is changed and the record gets commited.  
### See also

- [DynaPDF.GetFontsAsJSON](DynaPDFGetFontsAsJSON.md)
- [FoundationModels.Transcript](FoundationModelsTranscript.md)
- [IsError](IsError.md)
- [JSON.CreateArrayRef](JSONCreateArrayRef.md)
- [JSON.CreateObjectRef](JSONCreateObjectRef.md)
- [SharingService.ServicesForItems](SharingServiceServicesForItems.md)
- [SmartCard.SplitValues](SmartCardSplitValues.md)
- [Text.AddLineNumbers](TextAddLineNumbers.md)
- [Text.HTMLtoJSON](TextHTMLtoJSON.md)
- [WebRequest.GetHeaders](WebRequestGetHeaders.md)

### Release notes

- **Version 12.5**
    - Fixed [JSON.Colorize](https://www.mbsplugins.eu/JSONColorize.shtml) to work better with color for keys in nested objects.
- **Version 12.3**
    - You can now use english spelling [JSON.Colourise](https://www.mbsplugins.eu/JSONColorize.shtml) and [XML.Colourise](https://www.mbsplugins.eu/XMLColorize.shtml) if you prefer to call [JSON.Colorize](https://www.mbsplugins.eu/JSONColorize.shtml) or [XML.Colorize](https://www.mbsplugins.eu/XMLColorize.shtml).
- **Version 12.1**
    - Added darkMode parameter for [XML.Colorize](https://www.mbsplugins.eu/XMLColorize.shtml) and [JSON.Colorize](https://www.mbsplugins.eu/JSONColorize.shtml) function.
- **Version 11.5**
    - Fixed a problem in [JSON.Colorize](https://www.mbsplugins.eu/JSONColorize.shtml) function with coloring arrays.
- **Version 8.2**
    - Added [JSON.Colorize](http://www.mbsplugins.eu/JSONColorize.shtml) and [JSON.ToHTML](http://www.mbsplugins.eu/JSONToHTML.shtml) functions.

### Example Databases

- [Barcode/Barcode Detection](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Barcode/Barcode%20Detection.shtml#1ScriptAnchor_)
- [Files/Audio File Tags](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Files/Audio%20File%20Tags.shtml#1ScriptAnchor_)
- [JSON/JSON Import](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/JSON/JSON%20Import.shtml#4ScriptAnchor_)
- [Llama chat](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Llama%20chat.shtml#4ScriptAnchor_)
- [Mac and iOS/CGImageSource Properties](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/CGImageSource%20Properties.shtml#1ScriptAnchor_)
- [Mac and iOS/Contacts/Contacts](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/Contacts/Contacts.shtml#3ScriptAnchor_)
- [Mac and iOS/MapKit/Validate Address](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/MapKit/Validate%20Address.shtml#1ScriptAnchor_)
- [SmartCard/SmartCard ReadFile](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SmartCard/SmartCard%20ReadFile.shtml#12ScriptAnchor_)
- [Text functions/Text functions](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Text%20functions/Text%20functions.shtml#3ScriptAnchor_)
- [Win Only/Windows Location](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Win%20Only/Windows%20Location.shtml#2ScriptAnchor_)

### Blog Entries

- [Goodies 46: A format button for the data viewer](https://www.monkeybreadsoftware.com/filemaker/SyntaxColoring/46-FormatButtonDataViewer.shtml)
- [A format button for the data viewer](https://www.mbsplugins.de/archive/2025-07-16/A_format_button_for_the_data_v/monkeybreadsoftware_blog_filemaker)
- [Use MapKit to validate addresses](https://www.mbsplugins.de/archive/2024-02-15/Use_MapKit_to_validate_address/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin Advent calendar: 2 - Vision](https://www.mbsplugins.de/archive/2023-12-02/MBS_Plugin_Advent_calendar_2_-/monkeybreadsoftware_blog_filemaker)
- [Watch MongoDB Database](https://www.mbsplugins.de/archive/2023-11-04/Watch_MongoDB_Database/monkeybreadsoftware_blog_filemaker)
- [Query current found set with Execute FileMaker Data API as JSON](https://www.mbsplugins.de/archive/2023-10-31/Query_current_found_set_with_E/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 12.1 - More than 6700 Functions In One Plugin](https://www.mbsplugins.de/archive/2022-03-15/MBS_FileMaker_Plugin_121_-_Mor/monkeybreadsoftware_blog_filemaker)
- [XML and JSON Colorize for Dark Mode](https://www.mbsplugins.de/archive/2022-01-19/XML_and_JSON_Colorize_for_Dark/monkeybreadsoftware_blog_filemaker)
- [FileMaker Developers in Southern California](https://www.mbsplugins.de/archive/2021-03-15/FileMaker_Developers_in_Southe/monkeybreadsoftware_blog_filemaker)
- [With JSON in excellent form](https://www.mbsplugins.de/archive/2019-11-16/With_JSON_in_excellent_form/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 5/2020, Seite 15 bis 16](https://filemaker-magazin.de/neuigkeit/4110-Appetithappen-FMM_202005)

This function checks for a license.

Created 6th April 2018 , last changed 19th November 2025

  
[JSON.Clone](JSONClone.md) - [JSON.Compact](JSONCompact.md)

[HTML Version](JSONColorize.shtml)