# Unlayer Documentation > Unlayer is an embeddable, white-label drag-and-drop editor SDK that lets your users design responsive emails, landing pages, documents, and popups inside your own application. It pairs the visual builders with built-in AI — an assistant that edits designs from a chat prompt and an importer that turns HTML or screenshots into editable templates — plus a server-side Cloud API for exporting designs to HTML, PDF, images, and ZIP. These docs cover embedding and configuring the JavaScript builders (with React, Angular, and Vue wrappers), the AI features, deep white-label customization, the Cloud API, developer tools (CLI, headless React Elements, and AI coding-assistant Skills), and the portable design JSON data model. This file contains all documentation content in a single document following the llmstxt.org standard. ## Vanilla JS # Vanilla JS Setup This guide covers embedding Unlayer directly with plain HTML and JavaScript. No framework or build tools required. --- ## Step 1: Add the Embed Script Include the Unlayer embed script in your HTML page: ```html Unlayer Editor ``` --- ## Step 2: Initialize the Editor ```html ``` --- ## Step 3: Add Export and Save Buttons ```html ``` --- ## Complete Example ```html Unlayer Editor ``` --- ## Configuration Options Pass additional options to customize the builder: ```javascript unlayer.init({ id: 'editor-container', displayMode: 'email', appearance: { theme: 'modern_light', }, features: { textEditor: { spellChecker: true, }, }, }); ``` --- ## Loading a Saved Design ```javascript // After the editor is ready unlayer.addEventListener('editor:ready', function () { var savedDesign = /* fetch from your backend */; unlayer.loadDesign(savedDesign); }); ``` --- ## What's Next - Explore the full [Builders documentation](/builder/installation) for advanced options. - Consider using a [framework wrapper](/builder/react-component) for richer integration. --- ## Get Started with Unlayer Unlayer helps developers add content creation to their applications. Let users design emails, pages, images, and documents with drag-and-drop builders, while your app uses APIs and AI to generate, save, export, and automate content. Ship a complete content workflow without building the entire stack yourself. Pick a product and follow the step-by-step guide, or choose your framework below. ## Framework Setup Already know your stack? Wire up the SDK in your framework. ## How Unlayer Fits Together --- ## Export HTML Now that you have set up the editor in your application and users are creating content, it's time to save the resulting work i.e HTML. This is how you can export the design's HTML. :::tip Save Button Most applications will add a save button that calls this export function. ::: ```javascript unlayer.exportHtml(function (data) { var json = data.design; // design json var html = data.html; // final html // Do something with the json and html }); ``` ## Callback Parameters The exportHtml callback returns the following parameters. | Name | Description | | :--------- | :-------------------------------------------------------------------------------------------------------------------------------------------- | | **design** | This is the JSON of the design | | **html** | This is the full HTML of the design, starting with the opening `` tag to the closing `` tag. | | **chunks** | This includes the chunks of HTML separately in case you want to build your own layout. Check the [chunk parameters](#chunk-parameters) below. | --- ## Chunk Parameters The following chunks of HTML are available. | Name | Description | | :-------- | :--------------------------------------------------------------------------------------------------------------------------------------------------- | | **body** | This is the body part of the HTML that is added inside the `` tags. | | **css** | This is the CSS required for the design to render properly. You can add it inside the `` tags. | | **js** | This is the JS required for the design to render properly. You can add it inside the `` tags. | | **fonts** | This includes any web fonts or [custom fonts](../../advanced-configuration/font-management/custom-fonts.md) used in the design so you can load them. | --- ## Export Options You can also pass certain options to this function as a second parameter. ### Cleanup By default, we clean up the final HTML and remove unused HTML class names and CSS styles. If you want to disable that feature, you can pass `cleanup: false`. ```javascript unlayer.exportHtml( function (data) { var json = data.design; var html = data.html; }, { cleanup: true, }, ); ``` ### Minify By default, the HTML output is not minified or compressed. However, it is recommended to export the HTML minified and compressed as it can reduce the file size by up to 25%. ```javascript unlayer.exportHtml( function (data) { var json = data.design; var html = data.html; }, { minify: true, }, ); ``` ### Merge Tags If you want the [Merge Tags](../../advanced-configuration/dynamic-content/merge-tags.md) in your design to be replaced by different values, you can pass the `mergeTags` object to export options. ```javascript unlayer.exportHtml( function (data) { var json = data.design; var html = data.html; }, { mergeTags: { first_name: 'John', last_name: 'Doe', }, }, ); ``` ### Inline Styles Inline Styles options can be used to Inline the global css styles for links. This is useful in some instances for the email builder where Gmail or some other clients may not respect the link styles. By default, this is set to `false`. ```javascript unlayer.exportHtml( function (data) { var json = data.design; var html = data.html; }, { inlineStyles: true, }, ); ``` --- ## Cloud API You can also use our Cloud API if you want to export a design to HTML from a server-to-server API call. [Learn More](/server/cloud-api/reference#tag/export/operation/exportHtml) --- ## Export Image Similar to the [Export HTML](./export-html.md) function, you can also export a design in image format. This would upload the generated image to your connected [File Storage](../../files-storage/file-storage/overview.md) and send the link to the callback function. Note: Unlike HTML or plain text, images are not generated on the client. This function uses our cloud API to generate the image. ```javascript unlayer.exportImage(function (data) { var json = data.design; // design json var imageUrl = data.url; // image url // Do something with the image url }); ``` ## Callback Parameters The exportImage callback returns the following parameters. | Name | Description | | :--------- | :------------------------------------- | | **design** | This is the JSON of the design | | **url** | This is the URL of the generated image | --- ## Export Options You can also pass certain options to this function as a second parameter. ### Merge Tags If you want the [Merge Tags](../../advanced-configuration/dynamic-content/merge-tags.md) in your design to be replaced by different values, you can pass the `mergeTags` object to export options. ```javascript unlayer.exportImage( function (data) { var json = data.design; // design json var imageUrl = data.url; // image url }, { mergeTags: { first_name: 'John', last_name: 'Doe', }, }, ); ``` --- ### Full Page If you want the exported image to be the full page design, you can use this option. It is enabled by default. ```javascript unlayer.exportImage( function (data) { var json = data.design; // design json var imageUrl = data.url; // image url }, { fullPage: false, }, ); ``` --- ## Cloud API If you want to generate an image on the server-side, you can use our [Cloud API](/server/cloud-api/reference#tag/export/operation/exportImage). ```javascript const fetch = require('node-fetch'); let url = 'https://api.unlayer.com/v2/export/image'; let options = { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: 'Basic BASE64-ENCODED-API-KEY', }, body: JSON.stringify({ displayMode: 'email', design: {}, // json of your design mergeTags: { first_name: 'John', last_name: 'Doe' }, }), }; fetch(url, options) .then((res) => res.json()) .then((json) => console.log(json)) .catch((err) => console.error('error:' + err)); ``` Learn more at [Cloud API reference](/server/cloud-api/reference#tag/export/operation/exportImage). ### Response The API response will return an uploaded image URL. ```json { "success": true, "data": { "url": "https://.../1593082715347-8LCcNZuuBpU4D92W.png" } } ``` --- ## Export PDF Similar to the [Export HTML](./export-html.md) function, you can also export a design in PDF format. This would upload the generated PDF to your connected [File Storage](../../files-storage/file-storage/overview.md) and send the link to the callback function. Note: Unlike HTML or plain text, PDF is not generated on the client. This function uses our cloud API to generate the PDF. ```javascript unlayer.exportPdf(function (data) { var json = data.design; // design json var pdfUrl = data.url; // pdf url // Do something with the PDF url }); ``` ## Callback Parameters The exportPdf callback returns the following parameters. | Name | Description | | :--------- | :----------------------------------- | | **design** | This is the JSON of the design | | **url** | This is the URL of the generated PDF | --- ## Export Options You can also pass certain options to this function as a second parameter. ### Merge Tags If you want the [Merge Tags](../../advanced-configuration/dynamic-content/merge-tags.md) in your design to be replaced by different values, you can pass the `mergeTags` object to export options. ```javascript unlayer.exportPdf( function (data) { var json = data.design; // design json var pdfUrl = data.url; // pdf url }, { mergeTags: { first_name: 'John', last_name: 'Doe', }, }, ); ``` --- ## Cloud API If you want to generate the PDF on the server-side, you can use our [Cloud API](/server/cloud-api/reference#tag/export/operation/exportPdf). ```javascript const fetch = require('node-fetch'); let url = 'https://api.unlayer.com/v2/export/pdf'; let options = { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: 'Basic BASE64-ENCODED-API-KEY', }, body: JSON.stringify({ displayMode: 'email', design: {}, // json of your design mergeTags: { first_name: 'John', last_name: 'Doe' }, }), }; fetch(url, options) .then((res) => res.json()) .then((json) => console.log(json)) .catch((err) => console.error('error:' + err)); ``` Learn more at [Cloud API reference](/server/cloud-api/reference#tag/export/operation/exportPdf). ### Response The API response will return an uploaded pdf URL. ```json { "success": true, "data": { "url": "https://.../1593082715347-8LCcNZuuBpU4D92W.pdf" } } ``` --- ## Export Plain Text Similar to [Export HTML](./export-html.md), you can also export a design in plain text. This is useful if you want to send an email in multiple formats for different email clients. ```javascript unlayer.exportPlainText(function (data) { var json = data.design; // design json var text = data.text; // final text // Do something with the json and text }); ``` ## Callback Parameters The exportPlainText callback returns the following parameters. | Name | Description | | :--------- | :---------------------------------------- | | **design** | This is the JSON of the design | | **text** | This is the full plain text of the design | --- ## Export Options You can also pass certain options to this function as a second parameter. ### Omit Content You can configure which parts of the design you want to omit in the plain text. For example, you can choose to ignore images, links, or preheader text. ```javascript unlayer.exportPlainText( function (data) { var json = data.design; var text = data.text; }, { ignoreLinks: true, ignoreImages: true, ignorePreheader: true, }, ); ``` | Name | Description | | :------------------ | :---------------------------------------------- | | **ignoreLinks** | Links and buttons will not be included | | **ignoreImages** | Image alt text will not be included | | **ignorePreheader** | Pre-header text for emails will not be included | ### Merge Tags If you want the [Merge Tags](../../advanced-configuration/dynamic-content/merge-tags.md) in your design to be replaced by different values, you can pass the `mergeTags` object to export options. ```javascript unlayer.exportPlainText( function (data) { var json = data.design; var text = data.text; }, { mergeTags: { first_name: 'John', last_name: 'Doe', }, }, ); ``` --- ## Export ZIP Similar to the [Export HTML](./export-html.md) function, you can also export a design as a ZIP file. This generates a bundle ZIP file that also includes all the images required by your design and uploads it to your connected [File Storage](../../files-storage/file-storage/overview.md). Note: Unlike HTML or plain text, ZIP file is not generated on the client. This function uses our cloud API to generate the ZIP file. ```javascript unlayer.exportZip(function (data) { var json = data.design; // design json var fileUrl = data.url; // zip file url // Do something with the ZIP url }); ``` ## Callback Parameters The exportZip callback returns the following parameters. | Name | Description | | :--------- | :---------------------------------------- | | **design** | This is the JSON of the design | | **url** | This is the URL of the generated ZIP file | --- ## Export Options You can also pass certain options to this function as a second parameter. ### Merge Tags If you want the [Merge Tags](../../advanced-configuration/dynamic-content/merge-tags.md) in your design to be replaced by different values, you can pass the `mergeTags` object to export options. ```javascript unlayer.exportZip( function (data) { var json = data.design; // design json var fileUrl = data.url; // zip file url }, { mergeTags: { first_name: 'John', last_name: 'Doe', }, }, ); ``` --- ## Cloud API If you want to generate the ZIP file on the server-side, you can use our [Cloud API](/server/cloud-api/reference#tag/export/operation/exportZip). ```javascript const fetch = require('node-fetch'); let url = 'https://api.unlayer.com/v2/export/zip'; let options = { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: 'Basic BASE64-ENCODED-API-KEY', }, body: JSON.stringify({ displayMode: 'email', design: {}, // json of your design mergeTags: { first_name: 'John', last_name: 'Doe' }, }), }; fetch(url, options) .then((res) => res.json()) .then((json) => console.log(json)) .catch((err) => console.error('error:' + err)); ``` Learn more at [Cloud API reference](/server/cloud-api/reference#tag/export/operation/exportZip). ### Response The API response will return an uploaded zip file URL. ```json { "success": true, "data": { "url": "https://.../1593082715347-8LCcNZuuBpU4D92W.zip" } } ``` --- ## Installation This page will help you get started with Unlayer. You'll be up and running in a jiffy!