Validate Excalidraw JSON files after saving to catch syntax errors (missing commas, brackets, quotes).
Use Node.js built-in JSON parsing to validate the file:
node -e "JSON.parse(require('fs').readFileSync('FILE_PATH', 'utf8')); console.log('✓ Valid JSON')"
Replace FILE_PATH with the actual file path.
If invalid, Node.js will output:
SyntaxError: Expected ',' or '}' after property value
Fix: Add comma after the property value
SyntaxError: Unexpected end of JSON input
Fix: Add missing closing bracket ] or brace }
SyntaxError: Unexpected token ,
Fix: Remove the trailing comma before ] or }
SyntaxError: Unexpected token
Fix: Add missing quote around string value
After saving an Excalidraw file, run validation:
node -e "JSON.parse(require('fs').readFileSync('{{save_location}}', 'utf8')); console.log('✓ Valid JSON')"NEVER delete the file due to validation errors - always fix the syntax error at the reported location.