> ## Documentation Index
> Fetch the complete documentation index at: https://help.emaillove.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Email Love Core: render, import and plain text

> Use @email-love/core to render email-ready HTML from a design system and a document, import MJML or HTML, and make the plain-text part. Node or the browser.

`@email-love/core` is the engine under the editor. It renders an email from a design system and a document, checks documents, imports MJML or HTML, and applies editing operations. It has no database and no server, and it doesn't need React. It runs in Node and in the browser.

```sh theme={null}
npm install @email-love/core
```

TypeScript types are included.

## Render an email

```js theme={null}
import { renderEmail } from '@email-love/core'
import { starterDesignSystem, starterEmails } from '@email-love/core/starter'

const designSystem = starterDesignSystem()
const [welcome] = starterEmails()

const { ok, html, errors } = await renderEmail(designSystem, welcome.document)
```

`renderEmail(designSystem, document, options)` returns `{ ok, html, mjml, errors, warnings }`. `html` is email-ready HTML, with MJML underneath, tested across the inbox clients Email Love supports.

### Options

| Option | What it does |
| - | - |
| `mode` | `'export'` (the default) is what you send. `'preview'` with `annotate: true` marks sections and fields for an editor. |
| `assetBase` | Where the starter's few app-served pictures are: the logo, social icons, and carousel and accordion arrows. The default is `https://app.emaillove.com`. The design system's other pictures are on Email Love's CDN. |

## Import MJML or HTML

```js theme={null}
import { importMjml, importHtml } from '@email-love/core/import'
```

* `importMjml(mjml)` turns MJML into a design system and a document.
* `importHtml(html, designSystem)` turns an HTML email into a document built from the design system you pass.

## Plain text

```js theme={null}
import { plainTextOf } from '@email-love/core/plain-text'

const text = plainTextOf(html)
```

`plainTextOf(html)` gives the plain-text part of a finished email. Links and merge tags are kept.

## Everything in the package

| Import | What's in it |
| - | - |
| `@email-love/core` | `renderEmail`, `cleanDocument`, `createDesignSystem`, `documentOps` and `applyDocumentOps` |
| `@email-love/core/starter` | The Ultimate Email Design System (`starterDesignSystem()`) and its four emails (`starterEmails()`) |
| `@email-love/core/components` | `addComponents(designSystem, components)`: your own components, checked |
| `@email-love/core/format` | `checkDesignSystem(designSystem)`: what's wrong with a design system, in words |
| `@email-love/core/editing` | A headless editor: insert, move, duplicate and remove sections, set fields, undo and redo |
| `@email-love/core/preview` | `renderPreview(…)`: the marked-up preview an editor's canvas draws |
| `@email-love/core/import` | `importMjml(mjml)` and `importHtml(html, designSystem)` |
| `@email-love/core/plain-text` | `plainTextOf(html)`: the plain-text part, with links and merge tags kept |

For the document and design system formats, see [Design systems and your own components](https://help.emaillove.com/builder/sdk/design-systems.md) and [FORMAT.md](https://github.com/email-love/email-love-sdk/blob/main/packages/core/FORMAT.md).

## Contributing

Issues and pull requests are welcome on [GitHub](https://github.com/email-love/email-love-sdk). Sign off your commits with `git commit -s`, under the [Developer Certificate of Origin](https://developercertificate.org).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.