{"record":{"id":"8fd64805ae9cbd74","repo":"codex-team/editor.js","slug":"could-not-convert-block-tool-targettoolname","errorCode":null,"errorMessage":"Could not convert Block. Tool «${targetToolName}» not found.","messagePattern":"Could not convert Block\\. Tool «(.+?)» not found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/components/modules/blockManager.ts","lineNumber":847,"sourceCode":"   * @param blockDataOverrides - optional new Block data overrides\n   */\n  public async convert(blockToConvert: Block, targetToolName: string, blockDataOverrides?: BlockToolData): Promise<Block> {\n    /**\n     * At first, we get current Block data\n     */\n    const savedBlock = await blockToConvert.save();\n\n    if (!savedBlock) {\n      throw new Error('Could not convert Block. Failed to extract original Block data.');\n    }\n\n    /**\n     * Getting a class of the replacing Tool\n     */\n    const replacingTool = this.Editor.Tools.blockTools.get(targetToolName);\n\n    if (!replacingTool) {\n      throw new Error(`Could not convert Block. Tool «${targetToolName}» not found.`);\n    }\n\n    /**\n     * Using Conversion Config \"export\" we get a stringified version of the Block data\n     */\n    const exportedData = await blockToConvert.exportDataAsString();\n\n    /**\n     * Clean exported data with replacing sanitizer config\n     */\n    const cleanData: string = clean(\n      exportedData,\n      replacingTool.sanitizeConfig\n    );\n\n    /**\n     * Now using Conversion Config \"import\" we compose a new Block data\n     */","sourceCodeStart":829,"sourceCodeEnd":865,"githubUrl":"https://github.com/codex-team/editor.js/blob/5f45dabbe5690b7033b2f9047d3985add5045fdd/src/components/modules/blockManager.ts#L829-L865","documentation":"BlockManager.convert resolves the target tool by name from the tool registry; if targetToolName is not a registered block tool, conversion aborts with this error.","triggerScenarios":"Internal convert invoked with a tool name absent from Tools.blockTools: unregistered tool, misspelled name, or an inline tool name.","commonSituations":"Same as the API-level variant: converting to a tool not present in the editor's tools config.","solutions":["Register the target tool in the editor config","Verify the tool name against the registry before converting","Use editor.blocks.convert only with configured block tool names"],"exampleFix":"// before\neditor.config.tools = { paragraph: Paragraph };\neditor.blocks.convert(id, 'header');\n// after\neditor.config.tools = { paragraph: Paragraph, header: Header };\neditor.blocks.convert(id, 'header');","handlingStrategy":"validation","validationCode":"const registered = new Set(Object.keys(toolsConfig)); if (!registered.has(targetToolName)) throw new Error('register target tool first');","typeGuard":"const isRegisteredTool = (name: string, cfg: Record<string, unknown>): boolean => name in cfg;","tryCatchPattern":"try { await editor.blocks.convert(id, targetToolName); } catch (e) { if (e instanceof Error && e.message.includes('not found.')) { /* register tool, then retry */ } throw e; }","preventionTips":["Only convert to tools present in config","Keep tool names in a typed union"],"tags":["convert","tool-registry","not-found","editorjs"],"backgroundTag":"entity-not-found","analyzedSha":"5f45dabbe5690b7033b2f9047d3985add5045fdd","analyzedAt":"2026-08-27T22:50:23.124Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}