JSON Validator
CommunityValidate and format JSON strings directly in the chat.
Installation
Save as `json.js`.
Source Code
JavaScriptTutorial.terminal
// json.js
// Usage: Pass a JSON string as an argument
module.exports = async function(context) {
const input = context.args.join(' ');
try {
const obj = JSON.parse(input);
return {
valid: true,
formatted: JSON.stringify(obj, null, 2)
};
} catch (e) {
return {
valid: false,
error: e.message
};
}
};
Live Preview
β Live DemoAgent Session
How to use
- Ensure you have the necessary dependencies installed (if any).
- Place the file in your OpenClaw skills folder (e.g., ~/.openclaw/skills/).
- Restart your agent or reload configuration.
- Invoke it using the filename (without extension) as the tool name, or through natural language if the description is clear.