# toComponentEmbed

`function` in `discord-component-embed` · v0.2.2

<https://docs.seedcord.org/packages/discord-component-embed/0.2.2/functions/to-component-embed>

Converts a [`Container`](/packages/discord-component-embed/0.2.2/functions/container) tree into the JSON document Discord reads for a component embed. To write the JSON into a page, use [`toComponentEmbedJson`](/packages/discord-component-embed/0.2.2/functions/to-component-embed-json) or [`toComponentEmbedScript`](/packages/discord-component-embed/0.2.2/functions/to-component-embed-script). Both escape it for HTML.

```ts
toComponentEmbed(root: EmbedElement): ComponentEmbedPayload
```

Converts a [`Container`](/packages/discord-component-embed/0.2.2/functions/container) tree into the JSON document Discord reads for a component embed. To write the JSON into a page, use [`toComponentEmbedJson`](/packages/discord-component-embed/0.2.2/functions/to-component-embed-json) or [`toComponentEmbedScript`](/packages/discord-component-embed/0.2.2/functions/to-component-embed-script). Both escape it for HTML.

Parameters.

- `root` `EmbedElement`

Returns `ComponentEmbedPayload`.
