Overview
What Validate JSON does
Parses the complete selection and reports its top-level JSON type. Malformed input returns a specific JavaScript parsing error instead of changing the text.
| Category | Developer Tools |
|---|---|
| Action type | JavaScript |
| Result | Copy the result |
| Internet | Not required |
Example
Action and outcome
| Action | Outcome |
|---|---|
| Validate JSONSelected text: [1, 2, {"ready": true}] | Valid JSON — array. |
Workflow
Use Validate JSON
Follow these steps to check whether selected text is valid JSON with ActionClip.
- Select the text you want to use.
- Choose Validate JSON from ActionClip.
- Review the result, then copy it where you need it.
Before you add it
Requirements and privacy
- Before you start: No setup required.
- Your selected text: Runs locally in ActionClip’s JavaScript sandbox. Selected text does not leave your Mac.
Inspect before installing
Action configuration
The definition below is included so you can inspect how the action works before downloading it.
JavaScript definition
function run(selected_text) {
let value;
try {
value = JSON.parse(selected_text);
} catch (error) {
throw new Error("Invalid JSON: " + error.message);
}
const kind = value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
return "Valid JSON — " + kind + ".";
}