# toComponentEmbed

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

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

Converts a [`Container`](/packages/discord-component-embed/0.4.1/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.4.1/functions/to-component-embed-json) or [`toComponentEmbedScript`](/packages/discord-component-embed/0.4.1/functions/to-component-embed-script). Both escape it for a `<script>` tag.

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

Converts a [`Container`](/packages/discord-component-embed/0.4.1/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.4.1/functions/to-component-embed-json) or [`toComponentEmbedScript`](/packages/discord-component-embed/0.4.1/functions/to-component-embed-script). Both escape it for a `<script>` tag.

Parameters.

- `root` `EmbedElement`

Returns `ComponentEmbedPayload`.
