A simple utility function to export any MATLAB variable to a JSON file.
Usage
% Example data
data.name = "Alice";
data.scores = [95, 87, 76];
% Write compact JSON
writejson(data, "data.json", false);
% Write pretty-printed JSON (MATLAB R2021a or newer)
writejson(data, "prettyData.json", true); % equal to writejson(data, "prettyData.json")
Will result in
{
"name": "Alice",
"scores": [
95,
87,
76
]
}
Cite As
Joshua Bauske (2026). writeJSON (https://uk.mathworks.com/matlabcentral/fileexchange/182190-writejson), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2025b
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0 |
