Discord server widget code generator
Updated
Make the HTML for Discord's own server widget, see it working, and find out why it does not load if it does not. Enter your server ID, choose the look and the size, and copy the code into your site.
The tool needs JavaScript. The code's shape is shown below.
Find your server ID
- In Discord, open User Settings, then Advanced, and turn on Developer Mode.
- Right-click your server's icon and choose Copy Server ID.
A server ID is a number of 17 to 20 digits. A channel link holds two numbers: the first one is the server ID.
The widget also has to be switched on: in your server's settings, go to Engagement, then Server Widget, and turn on Enable Server Widget. Only members with the Manage Server permission can do this.
What the code looks like
With the default choices (dark, fits the page), the code has this shape, with your server ID in place of SERVER_ID:
<iframe src="https://discord.com/widget?id=SERVER_ID&theme=dark"
width="100%" height="500" style="max-width:350px"
allowtransparency="true" frameborder="0"
sandbox="allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"
title="Discord server widget"></iframe>
theme=lightgives the light look; anything else gives the dark one.- Fits the page sets the width to 100% of the column, up to a maximum width, so the widget does not overflow a phone screen. Fixed size sets a width and a height in pixels instead.
- The
sandboxvalue is the one widely quoted from Discord's ready-made code. The widget needsallow-scriptsto draw itself andallow-popupsfor its "Join Discord" link (see the widget is blank, or the frame is refused). - The
titlenames the widget for screen readers.
If you choose an image banner, you get a second piece of code: an image of https://discord.com/api/guilds/SERVER_ID/widget.png in the style you chose (shield or banner1 to banner4). It is a picture only, with no link. To make it clickable, put it inside a link to your server's invite.
What the check tells you
Preview loads the widget and asks Discord once for its widget data. You see one of these lines:
- Working, with your server's name and how many members are online. If no invite channel is set, it also says that there is no Join button: see there is no "Join Discord" button.
- The widget is turned off. Switch on Enable Server Widget, then wait up to five minutes: see turn the widget on. An image banner does not show until the widget is on.
- Discord does not know this server ID. It is usually a channel ID or a user ID: see use the server ID, not a channel ID.
- Discord did not answer. Discord may be limiting requests, or a browser extension may be blocking the request. Try again in a minute, and see the widget is blank, or the frame is refused.
Discord keeps its answer for up to five minutes. If you preview the same server again within five minutes, the tool says so: a change you just made in Discord may not show yet (see wait five minutes).
If the check says the widget works but your site shows nothing, the cause is on your site. The troubleshooting guide goes through each case.
What happens to what you enter
The tool runs in your browser. We do not receive your server ID, store it or count it, and the page sets no cookies and keeps nothing in your browser's storage.
When you press Preview, your browser talks to discord.com directly. It loads Discord's widget page into the preview: that page loads its own files and data from Discord, and your browser may send it your Discord cookies, as on any site that shows the widget. The tool also reads the widget data once, without your Discord cookies and without this page's address. Nothing loads while you type, and nothing is retried on its own.
If you wanted the chat itself
Discord's widget shows who is online, not your messages. To show a text channel live on your site and let visitors post, see how to embed a live Discord channel.