Email Builder
Emails that people and AI can design together.
A typed document model, an operations API for LLM agents, an email-safe HTML renderer and a modern React editor. One package, MIT licensed.
Documentation · Getting started · Agents · MCP
Why
AI is great at writing emails and bad at writing email HTML. Email Builder lets models and people edit the same structured document through the same validated operations, and leaves the HTML to a renderer that knows Outlook.
- 🧱 A document you can trust. Plain JSON with a Zod schema. Every change is validated, atomic and undoable.
- 📨 HTML that survives inboxes. Outlook-, Gmail- and mobile-safe HTML plus plain text, from pure TypeScript with no React and no DOM. Runs on servers, edge functions and from a CLI.
- 🤖 Built for agents. Provider-neutral tools, a system prompt generated from the schemas, and errors written so a model fixes its own mistakes.
- ✨ An editor people enjoy. Drag and drop, inline rich text, mobile preview, keyboard shortcuts, dark mode, translations, and shadcn/ui styling that matches your app.
- 👀 Review what the AI changed. AI edits arrive as a proposal the user accepts or rejects in one step.
- 🔌 MCP server included. Claude, Cursor and other AI clients can design emails in a folder of JSON files.
- ↪️ Easy to switch. EmailBuilder.js (
@usewaypoint/email-builder) designs convert with one call.
Install
npm install @maildun/email-builder
Quick start
Edit with the React editor:
import { EmailEditor } from '@maildun/email-builder/editor';
import '@maildun/email-builder/styles.css';
export function Compose() {
return (
<div style={{ height: '100vh' }}>
<EmailEditor defaultValue={design} onChange={save} />
</div>
);
}
Render the stored JSON anywhere:
import { renderEmail } from '@maildun/email-builder';
const { html, text, warnings } = renderEmail(design);
Generate with any LLM:
import { buildSystemPrompt, createAgentSession, runTool, toAnthropicTools } from '@maildun/email-builder/agent';
const session = createAgentSession(design);
// system: buildSystemPrompt(), tools: toAnthropicTools(session.tools)
// for each tool call: runTool(session.tools, call.name, call.input)
session.getDocument(); // the new design
Connect an AI client over MCP:
claude mcp add email-builder -- npx -y @maildun/email-builder mcp --dir ./emails
Documentation
The docs are also readable on GitHub in docs/.
Entry points
Contributing
bun install
bun run dev # playground at http://localhost:5173
bun run test
bun run docs:dev # this documentation at http://localhost:5174
See the contributing guide.
License
MIT. Parts of the UI and stylesheet come from shadcn/ui, Tailwind CSS and tw-animate-css (all MIT); see THIRD_PARTY_NOTICES.md. The EmailBuilder.js importer and font presets follow EmailBuilder.js (MIT) for compatibility.