| Components | All | New | MacOS | Windows | Linux | iOS | ||||
| Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old | |
JSON.Colorize
Formats a JSON string with color.
| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
| JSON | 8.2 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "JSON.Colorize"; JSON { ; DarkMode } ) More
(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.
// 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\"]")
Example result:
["Test","🍎","Escaped \uD83C\uDF4E"]
Example result:
["Test","🍎","Escaped \uD83C\uDF4E"]
Colorize and format in Auto-Enter calculation:
Let ( [
jsonFormatted = MBS("JSON.Format"; 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.
jsonFormatted = MBS("JSON.Format"; 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
- FoundationModels.Transcript
- IsError
- JSON.CreateArrayRef
- JSON.CreateObjectRef
- SharingService.ServicesForItems
- SmartCard.SplitValues
- Text.AddLineNumbers
- Text.HTMLtoJSON
- WebRequest.GetHeaders
Release notes
- Version 12.5
- Fixed JSON.Colorize to work better with color for keys in nested objects.
- Version 12.3
- You can now use english spelling JSON.Colourise and XML.Colourise if you prefer to call JSON.Colorize or XML.Colorize.
- Version 12.1
- Added darkMode parameter for XML.Colorize and JSON.Colorize function.
- Version 11.5
- Fixed a problem in JSON.Colorize function with coloring arrays.
- Version 8.2
- Added JSON.Colorize and JSON.ToHTML functions.
Example Databases
- CURL/Email/IMAP Email
- CURL/FTP/CURL FTP Directory Listing
- DynaPDF/PDF JSON
- JSON/JSON Colorized
- Mac and iOS/Contacts/Contacts
- Mac and iOS/Foundation Models
- MongoDB/MongoDB Test
- Network/Bonjour
- XML/XML and JSON
- XML/XML to JSON
Blog Entries
- Goodies 46: A format button for the data viewer
- A format button for the data viewer
- Use MapKit to validate addresses
- MBS Plugin Advent calendar: 2 - Vision
- Watch MongoDB Database
- Query current found set with Execute FileMaker Data API as JSON
- MBS FileMaker Plugin 12.1 - More than 6700 Functions In One Plugin
- XML and JSON Colorize for Dark Mode
- FileMaker Developers in Southern California
- With JSON in excellent form
FileMaker Magazin
This function checks for a license.
Created 6th April 2018, last changed 19th November 2025