# toComponentEmbed

`function` in `discord-component-embed` · v1.0.0

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

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

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

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

Parameters.

- `root` `EmbedElement`

Returns `ComponentEmbedPayload`.
