Go to Sign up
Note: Your files never leave your device. We don't upload, transfer, or store your data.
MATLAB (Matrix Laboratory) is a numerical computing environment and programming language developed by MathWorks. It is widely used in engineering, science, finance, and academic research for data analysis, signal processing, control systems, and machine learning.
Key properties:
| Property | Description |
|---|---|
| Matrix-centric | All data is fundamentally a matrix (2D array) |
| Numeric focus | Optimized for numerical computation |
| Toolboxes | Extended functionality via domain-specific toolboxes |
| Plotting | Built-in 2D/3D visualization |
| File formats | .m scripts, .mat data files |
JSON (JavaScript Object Notation) is a lightweight, human-readable text format defined by RFC 8259. It uses key-value pairs and ordered lists to represent structured data.
| Use Case | Description |
|---|---|
| Data import | Load JSON API responses or config files into MATLAB workspace |
| Research data | Convert experimental data stored as JSON into MATLAB arrays for analysis |
| Signal processing | Import sensor data from JSON logs into MATLAB for filtering and FFT |
| Machine learning | Prepare training data from JSON into MATLAB matrix format |
| Simulation | Load simulation parameters from JSON into MATLAB models |
| Migration | Port data from web/Python workflows into MATLAB |
| Testing | Generate MATLAB test fixtures from JSON samples |
MATLAB has three primary data structures for representing JSON data. Choosing the right one depends on your data.
A cell array can hold mixed data types — strings, numbers, booleans, and nested cells. Use this when your JSON contains heterogeneous data.
data = {
'Alice', 30, true;
'Bob', 25, false;
'Charlie', 35, true
};
| Aspect | Details |
|---|---|
| Best for | Mixed-type data (strings + numbers + booleans) |
| Access | data{row, col} (curly braces) |
| Flexibility | Each cell can hold any type |
| JSON mapping | Default choice — handles all JSON types |
A numeric matrix (2D array) holds only numbers. Use this when your JSON contains purely numeric data — all strings and booleans are excluded.
data = [
1, 3.14, 42;
2, 2.72, 17;
3, 1.41, 99
];
| Aspect | Details |
|---|---|
| Best for | Purely numeric data (measurements, coordinates, matrices) |
| Access | data(row, col) (parentheses) |
| Performance | Fastest — native MATLAB matrix operations |
| JSON mapping | Only numeric fields are included; non-numeric fields are skipped |
A struct array uses named fields. Each element is a struct with field names matching the JSON object keys. Use this when you need key-based access.
data(1).name = 'Alice';
data(1).age = 30;
data(2).name = 'Bob';
data(2).age = 25;
| Aspect | Details |
|---|---|
| Best for | Keyed objects where field names matter |
| Access | data(1).name (dot notation) |
| Readability | Self-documenting — field names preserved |
| JSON mapping | JSON objects → struct fields |
| JSON Type | JSON Example | Cell Array | Numeric Matrix | Struct Field |
|---|---|---|---|---|
| String | "hello" | 'hello' | (excluded) | 'hello' |
| Integer | 42 | 42 | 42 | 42 |
| Float | 3.14 | 3.14 | 3.14 | 3.14 |
| Boolean true | true | true | 1 | true |
| Boolean false | false | false | 0 | false |
| Null | null | (see NaN option) | NaN | (see NaN option) |
| Object | {"a": 1} | Nested cell | (excluded) | Nested struct |
| Array | [1, 2] | [1, 2] | Row in matrix | Vector field |
File Upload: Drag and drop or select a .json file.
Code Editor: Paste or type raw JSON with syntax highlighting and real-time validation.
Set the MATLAB variable name for the output. This becomes the assignment target in the generated code.
% Variable Name = "sensorData"sensorData = {...};Rules:
Must start with a letter
Can contain letters, digits, and underscores
Case-sensitive
No spaces or special characters
| Type | When to Use |
|---|---|
| Cell Array | Mixed data (strings + numbers) — safest default |
| Numeric Matrix | Purely numeric data (measurements, coordinates) |
| Struct Array | Keyed objects where you need data(1).field access |
Cell Array output:
myData = {
'Alice', 30, true;
'Bob', 25, false
};
Numeric Matrix output:
myData = [
1, 30, 1;
2, 25, 0
];
Struct Array output:
myData(1).name = 'Alice';
myData(1).age = 30;
myData(1).active = true;
myData(2).name = 'Bob';
myData(2).age = 25;my
Data(2).active = false;
| Option | Syntax | Notes |
|---|---|---|
| Single Quote | 'hello' | Traditional MATLAB syntax (all versions) |
| Double Quote | "hello" | Introduced in MATLAB R2017a for string arrays |
For maximum compatibility, use Single Quote. Use Double Quote if you work with MATLAB's string type (R2017a+).
Adds comments at the top of the output showing column headers and metadata:
% Generated by A.Tools — JSON To MATLAB Array
% Columns: name, age, active
% Rows: 3
myData = {...};
Transposes the output matrix — rows become columns and columns become rows. Useful when:
You need data organized by column (variable) instead of by row (observation)
Feeding data into MATLAB functions that expect column vectors
Matching MATLAB's column-major convention
Without transpose:
data = [
1, 2, 3;
4, 5, 6
];
% 2 rows × 3 columns
With transpose:
data = [
1, 4;
2, 5;
3, 6
];
% 3 rows × 2 columns
Controls how JSON null and empty values are represented in MATLAB output:
| Option | Output | Best For |
|---|---|---|
| NaN | NaN | Numeric matrices — isnan() filtering |
| '' | '' (empty string) | Cell arrays with string data |
| [] | [] (empty array) | General-purpose — MATLAB's "empty" convention |
Example:
% JSON: {"a": 1, "b": null, "c": 3}
% NaN option:
data = [1, NaN, 3];
% '' option (cell array):
data = {1, '', 3};
% [] option:
data = {1, [], 3};
All processing runs entirely in your browser. No data is uploaded to any server.
Choose one of two input methods:
Upload a file: Click "Choose File" and select a .json file, or drag it into the upload area.
Paste data: Click "Enter Data" to switch to the code editor. Paste your JSON array. A "Valid JSON" badge confirms correct formatting.
Important: The tool expects a JSON array.
Use the Properties panel on the right:
Variable Name: Enter a valid MATLAB variable name (e.g., sensorData, results).
Output Type: Select Cell Array (mixed), Numeric Matrix (numbers only), or Struct Array (keyed).
String Delimiter: Choose Single Quote (compatible) or Double Quote (R2017a+).
Output Options: Check Header Comments and/or Transpose as needed.
NaN / Missing: Choose how null/empty values are represented.
Click Convert. The MATLAB code appears in the "Output Data" panel.
Click Copy to Clipboard to paste into your .m file.
Premium users can click Download File to save.
Input JSON:
[
{"name": "Alice", "age": 30, "active": true},
{"name": "Bob", "age": 25, "active": false},
{"name": "Charlie", "age": 35, "active": true}
]
Configuration:
Variable Name: users
Output Type: Cell Array
String Delimiter: Single Quote
Header Comments: On
Transpose: Off
NaN / Missing: NaN
Output:
% Generated by A.Tools — JSON To MATLAB Array
% Columns: name, age, active
users = {
'Alice', 30, true;
'Bob', 25, false;
'Charlie', 35, true
};
Input JSON:
[
{"x": 1.0, "y": 2.5, "z": 0.8},
{"x": 1.5, "y": 3.0, "z": 1.2},
{"x": 2.0, "y": 3.5, "z": 0.5},
{"x": 2.5, "y": 4.0, "z": 1.8}
]
Configuration:
Variable Name: coords
Output Type: Numeric Matrix
Transpose: On
Output:
coords = [
1.0, 1.5, 2.0, 2.5;
2.5, 3.0, 3.5, 4.0;
0.8, 1.2, 0.5, 1.8
];
Input JSON:
[
{"sensor": "temp_01", "reading": 23.5, "unit": "celsius"},
{"sensor": "temp_02", "reading": 19.8, "unit": "celsius"},
{"sensor": "humid_01", "reading": 65.2, "unit": "percent"}
]
Configuration:
Variable Name: readings
Output Type: Struct Array
Output:
readings(1).sensor = 'temp_01';
readings(1).reading = 23.5;
readings(1).unit = 'celsius';
readings(2).sensor = 'temp_02';
readings(2).reading = 19.8;
readings(2).unit = 'celsius';
readings(3).sensor = 'humid_01';
readings(3).reading = 65.2;
readings(3).unit = 'percent';
Input JSON:
[
{"id": 1, "score": 95, "bonus": 10},
{"id": 2, "score": null, "bonus": 5},
{"id": 3, "score": 88, "bonus": null}
]
Configuration:
Output Type: Numeric Matrix
NaN / Missing: NaN
Output:
data = [
1, 95, 10;
2, NaN, 5;
3, 88, NaN
];
Filter NaN values in MATLAB:
% Remove rows with any NaN
cleanData = data(~any(isnan(data), 2), :);
MATLAB R2016b+ has a built-in jsondecode() function.
jsonStr = fileread('data.json');
data = jsondecode(jsonStr);
| Aspect | jsondecode() |
|---|---|
| When to use | Dynamic JSON from files, APIs, user input |
| Output | Always struct or cell array |
| Customization | No control over variable name, delimiter, NaN handling |
| Performance | Parses at runtime |
| Aspect | This Tool |
|---|---|
| When to use | Static data, hardcoded arrays, testing, scripts |
| Output | Choose cell array, numeric matrix, or struct array |
| Customization | Variable name, delimiter, transpose, NaN handling |
| Performance | No parsing overhead — data is literal MATLAB code |
% From JSON API response to MATLAB numeric matrix
sensorData = [
1633036800, 23.5, 45.2, 1013.1;
1633037100, 23.8, 44.8, 1013.0;
1633037400, 24.1, 43.5, 1012.8
];
% Plot temperature over time
plot(sensorData(:,1), sensorData(:,2));
xlabel('Timestamp');
ylabel('Temperature (C)');
results(1).trial = 1;
results(1).accuracy = 0.95;
results(1).loss = 0.12;
results(2).trial = 2;
results(2).accuracy = 0.97;
results(2).loss = 0.08;
% Numeric matrix from JSON — ready for linear algebra
A = [
1, 2, 3;
4, 5, 6;
7, 8, 9
];
eigenvalues = eig(A);
rank_A = rank(A);
det_A = det(A);
No. All conversion happens locally in your browser using JavaScript. Your data never leaves your device.
Cell Array holds mixed types (strings, numbers, booleans) — use for general JSON data. Numeric Matrix holds only numbers — use for pure numeric data. Struct Array uses named fields — use when you need data(1).fieldName access.
Use Single Quote ('text') for maximum compatibility with all MATLAB versions. Use Double Quote ("text") only if you need MATLAB's string type (R2017a+).
It swaps rows and columns. Without transpose, each JSON object becomes a row. With transpose, each JSON field becomes a column vector — matching MATLAB's column-major convention.
Choose from three options: NaN (numeric not-a-number), '' (empty string), or [] (empty array). NaN is best for numeric matrices; empty string for cell arrays; empty array for general use.
Yes. Copy the output and paste it into MATLAB Online or MATLAB desktop.
A JSON array. Arrays of objects produce the best results: [{"key": "value"}, ...]. Arrays of primitives are also supported.
The tool processes data entirely in your browser. Files up to 10 MB typically convert without issues on modern hardware.
Yes. The tool is responsive and works on smartphones and tablets.