{"record":{"id":"a0d71425549efacd","repo":"GrapesJS/grapesjs","slug":"parser-code-parsercode-not-found","errorCode":null,"errorMessage":"Parser code \"${parserCode}\" not found","messagePattern":"Parser code \"(.+?)\" not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/parser/model/ParserHtml.ts","lineNumber":487,"sourceCode":"    res.html = resHtml;\n    Parser?.__emitEvent(ParserEvents.html, { input, output: res, options });\n\n    return res;\n  }\n\n  __getSyntheticNode(node: ParsedNodeMeta, opts: ParserHtmlInternalOptions) {\n    const parserConfig = this.em?.Parser?.getConfig() || this.config;\n    const SyntheticElement =\n      opts.__syntheticElementCtor || getSyntheticElementCtor(parserConfig.customSyntheticElement);\n    return new SyntheticElement(node);\n  }\n\n  __parseInput(input: string, options: HTMLParserOptions, cf: ParserConfig, parserCode: string) {\n    const codeParser = parserCode ? this.em?.Parser?.getParserCode(parserCode) : undefined;\n    const { asDocument } = options;\n\n    if (parserCode) {\n      if (!codeParser) throw new Error(`Parser code \"${parserCode}\" not found`);\n\n      const parsedNode = codeParser.parse(input, { editor: this.em?.getEditor()!, options });\n      const parsedNodes = isArray(parsedNode) ? parsedNode : [parsedNode];\n\n      return {\n        root: asDocument ? normalizeDocumentRoot(parsedNodes) : createFragmentRoot(parsedNodes),\n        isParsedMode: true,\n      };\n    }\n\n    const parseRes = isFunction(cf.parserHtml) ? cf.parserHtml(input, options) : BrowserParserHtml(input, options);\n\n    return {\n      root: asDocument\n        ? domDocumentToParsedNode(parseRes as Document)\n        : domRootToFragmentParsedNode(parseRes as HTMLElement),\n      isParsedMode: false,\n    };","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/GrapesJS/grapesjs/blob/2bdeda85b82b8b9ceae42fd6558cbbcae5ec2d21/packages/core/src/parser/model/ParserHtml.ts#L469-L505","documentation":"ParserHtml's `__parseInput` lets callers supply a custom `parserCode` id that must be registered via `Parser.addParserCode`/parser registry. If a parser id is given but no parser with that code is registered, parsing cannot proceed and it throws.","triggerScenarios":"Parsing HTML with options like `{ parserCode: 'myParser' }` (or a component/model config referencing one) before registering that parser via `editor.Parser.addParserCode(id, parser)`; typos in the parser id; calling the internal `__parseInput` with an unregistered code.","commonSituations":"Custom HTML/JSX parsers set up in the wrong order (parse before plugin registration), misconfigured parser options, using a parser id from an old GrapesJS version after API changes.","solutions":["Register the parser before use: `editor.Parser.addParserCode('myParser', myParser)`.","Fix the parser id typo in the options/config.","Remove the `parserCode` option if default parsing is sufficient.","Ensure the plugin registering the parser loads before any `editor.setComponents`/parse call."],"exampleFix":"// before\neditor.setComponents(html, { parserCode: 'jsx' }); // 'jsx' never registered\n// after\neditor.Parser.addParserCode('jsx', jsxParser);\neditor.setComponents(html, { parserCode: 'jsx' });","handlingStrategy":"validation","validationCode":"const parserIds = ['html', 'css', 'myParser'];\nfor (const id of parserIds) {\n  if (!editor.Parser.getParserCode(id)) {\n    throw new Error(`Parser \"${id}\" must be registered via Parser.addParserCode before use`);\n  }\n}","typeGuard":"function hasParser(em, code) {\n  return Boolean(em?.Parser?.getParserCode?.(code));\n}","tryCatchPattern":"try {\n  editor.setComponents(html, { parserCode: 'myParser' });\n} catch (err) {\n  if (err.message.startsWith('Parser code')) {\n    editor.Parser.addParserCode('myParser', myParser);\n    editor.setComponents(html, { parserCode: 'myParser' });\n  } else throw err;\n}","preventionTips":["Register custom parsers in a plugin that loads before any parse/setComponents call","Keep parser ids in a constant shared between registration and usage","Verify parser support for your GrapesJS version (addParserCode API)"],"tags":["grapesjs","parser","missing-registration","configuration"],"backgroundTag":"unregistered-parser-id","analyzedSha":"2bdeda85b82b8b9ceae42fd6558cbbcae5ec2d21","analyzedAt":"2026-08-30T11:47:52.267Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}