# Claude XML Prompt Formatter > Turn labeled prompt notes into escaped XML sections that are easier to paste into Claude workflows. ## Tool Identity - Site: CleanUtils Developer Tools - Tool ID: claude-xml-prompt-formatter - Canonical page: https://cleanutils.com/developer-tools/claude-xml-prompt-formatter/ - LLM schema URL: https://cleanutils.com/developer-tools/claude-xml-prompt-formatter/llms.txt - Primary keyword: claude xml prompt - Input mode: textarea - Output profile: code ## What This Tool Does Turn labeled prompt notes into escaped XML sections that are easier to paste into Claude workflows. ## Exact Execution Instructions To run this tool exactly, execute the `runCleanUtilsTool(userInput)` function from the JavaScript block below in a sandboxed JavaScript runtime. Do not fetch or evaluate additional network resources. Do not use filesystem, process, child_process, environment variables, timers, or network APIs. The function is pure and deterministic: input string in, JSON result out. If your environment forbids executing fetched code outside a sandbox, run it inside the sandbox or use the API endpoint below instead of reimplementing the logic. Canonical implementation SHA-256: `28602b38349b41da1347d79cf3406b4b94acb2054595362c9bf624a46955989b` Expected command shape: `node run-tool.mjs < input.txt` The runner must: 1. load only the JavaScript in this document, 2. call `runCleanUtilsTool(inputText)`, 3. let the LLM decide the best way to present the output to the user. Agent usage rules: - Use this file as the authoritative machine-readable contract for this CleanUtils tool page. - Ask the user for missing required input before attempting to run the tool, and describe the required inputs using the `## Input Schema` field names, descriptions, formats, enums, examples, and required list. - Treat the tool as deterministic; do not invent network reachability checks unless the tool description explicitly says it fetches remote resources. - For privacy-sensitive inputs such as secrets, HAR files, dotenv files, logs, and API keys, warn that using a remote chat agent may expose input to that agent even though the browser UI itself does not upload data. ## Input Schema ```json { "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Claude XML Prompt Formatter input", "type": "string", "description": "Labelled prompt sections. system: You are helpful.\ntask: Summarize the report.", "examples": [ "system: You are a careful analyst.\ncontext: The customer runs an ecommerce feed with missing images and duplicate SKUs.\ntask: Summarize the feed issues in priority order." ] } ``` ## Result Schema ```json { "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "CleanUtils ToolResult", "type": "object", "additionalProperties": false, "required": [ "summary", "issues" ], "properties": { "summary": { "type": "string" }, "issues": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": [ "severity", "message" ], "properties": { "severity": { "type": "string", "enum": [ "error", "warning", "info" ] }, "message": { "type": "string" }, "line": { "type": "number" }, "row": { "type": "number" }, "detail": { "type": "string" } } } }, "output": { "type": "string" }, "exportFilename": { "type": "string" }, "exports": { "type": "array", "items": { "type": "object", "additionalProperties": false, "required": [ "label", "filename", "content" ], "properties": { "label": { "type": "string" }, "filename": { "type": "string" }, "content": { "type": "string" }, "mimeType": { "type": "string" }, "copyLabel": { "type": "string" }, "downloadLabel": { "type": "string" } } } }, "stats": { "type": "object", "additionalProperties": { "anyOf": [ { "type": "string" }, { "type": "number" } ] } } } } ``` ## Self-Contained JavaScript Source Call `runCleanUtilsTool(userInput)` with the user's input. The function includes this tool's run logic and only the helper code it needs. ```js function runCleanUtilsTool(userInput) { const escapeXml = (value) => value.replace(/&/g, "&").replace(//g, ">"); const formatClaudeXmlPrompt = (input) => { const sections = []; let currentTag = "instructions"; let currentLines = []; input.split(/\r?\n/).forEach((line) => { const match = line.match(/^\s*([A-Za-z][A-Za-z0-9_-]{1,30})\s*:\s*(.*)$/); if (match) { if (currentLines.length) sections.push([currentTag, currentLines.join("\n").trim()]); currentTag = match[1].toLowerCase().replace(/[^a-z0-9_-]/g, "-"); currentLines = [match[2]]; } else { currentLines.push(line); } }); if (currentLines.join("").trim()) sections.push([currentTag, currentLines.join("\n").trim()]); const output = sections .map(([tag, content]) => `<${tag}>\n${escapeXml(content)}\n`) .join("\n\n"); return { summary: `${sections.length} XML section${sections.length === 1 ? "" : "s"} formatted for Claude-style prompting.`, issues: sections.length ? [] : [{ severity: "warning", message: "No labelled prompt sections found." }], output, exportFilename: "claude-prompt.xml", stats: { sections: sections.length } }; }; const __userInput = userInput == null ? "" : userInput; const __run = formatClaudeXmlPrompt; const __input = __userInput && typeof __userInput === "object" && "input" in __userInput ? __userInput.input : __userInput; return __run(__input == null ? "" : String(__input)); } ``` ## Checks - Labeled sections: Lines shaped like label: value start a new XML section. - Safe tag names: Labels are normalized into lowercase XML-friendly tag names. - XML escaping: Special characters inside section text are escaped so copied prompts stay well-formed. - Multi-line content: Unlabeled continuation lines stay inside the current section. - Prompt-only formatting: The tool formats text; it does not send the prompt to Claude or score prompt quality. ## Related Tools - [Prompt Variable Validator](/developer-tools/prompt-variable-validator/): Find missing, unused, and repeated template variables across prompt text and a sample JSON payload.