ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified

openclaw-json-editing

Advanced JSON editing for OpenClaw configuration files, tools, and data structures. Handles JSON5 configs, schema validation, merge patching, env var substitution, and type-safe modifications.

skill-install — Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/avirweb/openclaw-json-editing
Or

OpenClaw JSON Editing

Expert guidance for editing JSON in the OpenClaw ecosystem. OpenClaw uses JSON5 for configuration (allows comments, trailing commas), has sophisticated config merging, and validates with Zod schemas.

Quick Reference

TaskCommand/Pattern
Validate configopenclaw config validate
Apply config patchopenclaw config patch <file.json>
Safe JSON parseUse safeParseJson() wrapper
Check config locationopenclaw config path
Pretty printJSON.stringify(data, null, 2)

OpenClaw JSON5 Config

OpenClaw config files use JSON5 (not strict JSON):

{
  // Single-line comments are allowed
  "gateway": {
    "mode": "http",  // Trailing commas are allowed
  },
  /* Multi-line comments
     are also supported */
  "agents": {
    "main": {
      "model": "anthropic/claude-opus-4-6",
    },
  },
}

Key Differences from JSON

  • Comments: Single-line (//) and multi-line (/* */)
  • Trailing commas: Allowed in arrays and objects
  • Unquoted keys: { key: "value" } is valid
  • Single quotes: 'string' is valid

Config File Locations

TypePath
User config~/.openclaw/config.json
Project config./openclaw.config.json
Agent config~/.openclaw/agents/<id>/config.json
Session store~/.openclaw/sessions/
State dir~/.openclaw/ (or $OPENCLAW_STATE_DIR)

Safe JSON Operations

Reading Config Files

OpenClaw uses JSON5.parse() for configs and safe wrappers:

// OpenClaw's safeParseJson pattern
function safeParseJson<T>(raw: string): T | null {
  try {
    return JSON.parse(raw) as T;
  } catch {
    return null;
  }
}

// For OpenClaw configs, use JSON5
import JSON5 from "json5";

function loadConfigFile(path: string): unknown {
  try {
    const raw = fs.readFileSync(path, "utf8");
    return JSON5.parse(raw);  // Allows comments, trailing commas
  } catch {
    return undefined;
  }
}

Writing Config Files

OpenClaw writes with specific formatting and permissions:

function saveJsonFile(pathname: string, data: unknown) {
  const dir = path.dirname(pathname);
  if (!fs.existsSync(dir)) {
    fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
  }
  // 2-space indentation, trailing newline
  fs.writeFileSync(pathname, `${JSON.stringify(data, null, 2)}\n`, "utf8");
  fs.chmodSync(pathname, 0o600);  // User read/write only
}

Type Guards

Always validate before assuming structure:

// OpenClaw's isPlainObject (strictest)
function isPlainObject(value: unknown): value is Record<string, unknown> {
  return (
    typeof value === "object" &&
    value !== null &&
    !Array.isArray(value) &&
    Object.prototype.toString.call(value) === "[object Object]"
  );
}

Metadata

Author@avirweb
Stars4473
Views1
Updated2026-05-01
View Author Profile
AI Skill Finder

Not sure this is the right skill?

Describe what you want to build — we'll match you to the best skill from 16,000+ options.

Find the right skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-avirweb-openclaw-json-editing": {
      "enabled": true,
      "auto_update": true
    }
  }
}
Safety NoteClawKit audits metadata but not runtime behavior. Use with caution.