Developer Tools

Validate JSON

Check whether selected text is valid JSON.

OfficialOn-device

Download action

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.

CategoryDeveloper Tools
Action typeJavaScript
ResultCopy the result
InternetNot required

Action and outcome

Validate JSON example
ActionOutcome
Validate JSONSelected text: [1, 2, {"ready": true}]Valid JSON — array.

Use Validate JSON

Follow these steps to check whether selected text is valid JSON with ActionClip.

  1. Select the text you want to use.
  2. Choose Validate JSON from ActionClip.
  3. Review the result, then copy it where you need 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.

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 + ".";
}