writeJSON

Save a MATLAB variable to a JSON file.
2 Downloads
Updated 2 Oct 2025

View License

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 (2025). writeJSON (https://se.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 Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0