How to Create a Discord Online Users Widget for Your Website

Learn how to create and embed a live Discord online users widget on your website. Step-by-step guide with screenshots and code examples.

6 min read •
403 8 5

How to Add a Discord Online Users Widget to Your Website

Looking for an easy way to show your Discord server activity on your website? With a few quick steps, you can embed a live Discord widget that shows who’s online and includes a direct invite link. It’s perfect for building trust and growing your community.

Reading time: ~5 min Keywords: Discord online widget, Discord JSON API, live member count

Why Add a Discord Widget?

Whether you’re running a gaming hub, developer server, or support community, a Discord online users widget boosts credibility and conversions:

  • Shows your server is active-visitors see real-time online users.
  • Encourages people to join-a one-click invite accelerates growth.
  • Makes your site feel alive-great for brand- and community-driven platforms.

Step 1-Open Your Server Settings

Open Discord and go to your server. Click the server name in the top-left, then choose Server Settings. This is where you’ll enable the widget feature.

Open Server Settings in Discord
Navigate to Server Settings to access the widget options.

Step 2-Turn On the Server Widget

Enable Discord Widget Option
Enable the Server Widget under the Engagement section.

Inside Engagement, toggle on Server Widget. Discord will expose a public endpoint that powers your widget with live data.


Step 3-Grab Your Widget JSON URL

Once enabled, you’ll see an API URL similar to:

https://discord.com/api/guilds/YOUR_SERVER_ID/widget.json
https://discord.com/api/guilds/YOUR_SERVER_ID/widget.json

This Discord JSON API returns real-time presence, member avatars, and an invite link, perfect for a lightweight custom widget.

Discord Widget JSON API URL
Copy the JSON endpoint to use it in your site’s code.

Step 4-Embed the Widget on Your Site

Below is a minimal, Bootstrap-friendly implementation. Replace YOUR_API_URL and YOUR_INVITE with your values.

🔹 CSS: Basic Styling

<style>
  #discord-widget {
    background-color: var(--bs-light);
    border-left: .25rem solid #5865F2;
    transition: box-shadow .2s ease-in-out;
  }
  #discord-widget:hover { box-shadow: 0 .5rem 1rem rgba(0,0,0,.1); }
  #discord-avatars img {
    width: 24px; height: 24px; object-fit: cover;
  }
</style>

🔸 HTML: Widget Structure

<div id="discord-widget" class="p-3 rounded shadow-sm text-center">
  <h5 class="mb-1">Join Our Community</h5>
  <p id="discord-online" class="text-muted mb-3">Loading...</p>
  <div id="discord-avatars" class="d-flex justify-content-center flex-wrap gap-2 my-3"></div>
  <a href="https://discord.gg/YOUR_INVITE" class="btn btn-primary">
    <i class="bi bi-discord me-1"></i> Join Now
  </a>
</div>

🟢 JavaScript: Load the Live Data

<script>
  (function(){
    const API_URL = 'YOUR_API_URL';
    const onlineEl = document.getElementById('discord-online');
    const avatarsEl = document.getElementById('discord-avatars');

    fetch(API_URL, { cache: 'no-store' })
      .then(r => r.json())
      .then(data => {
        onlineEl.textContent = `${data.presence_count} users online`;
        avatarsEl.innerHTML = '';
        (data.members || []).slice(0, 40).forEach(m => {
          const img = document.createElement('img');
          img.src = m.avatar_url;
          img.alt = m.username;
          img.className = 'rounded-circle';
          img.setAttribute('data-bs-toggle', 'tooltip');
          img.title = m.username;
          avatarsEl.appendChild(img);
        });
        // Init Bootstrap tooltips lazily
        const tts = document.querySelectorAll('[data-bs-toggle="tooltip"]');
        [...tts].forEach(el => new bootstrap.Tooltip(el));
      })
      .catch(() => {
        onlineEl.textContent = 'Unable to load status';
      });

    // Copy helpers for buttons
    document.querySelectorAll('[data-copy-prev]').forEach(btn => {
      btn.addEventListener('click', () => {
        const code = btn.parentElement.querySelector('pre').innerText;
        navigator.clipboard.writeText(code.trim());
        btn.innerText = 'Copied!';
        setTimeout(() => (btn.innerText = 'Copy'), 1500);
      });
    });
    document.querySelectorAll('[data-copy-target]').forEach(btn => {
      btn.addEventListener('click', () => {
        const target = document.querySelector(btn.getAttribute('data-copy-target'));
        navigator.clipboard.writeText(target.textContent.trim());
        btn.innerText = 'Copied!';
        setTimeout(() => (btn.innerText = 'Copy'), 1500);
      });
    });
  })();
</script>

Step 5-Make It Yours

  • Match your branding: tweak fonts, colors, spacing via Bootstrap utilities.
  • Avatar size: change 24px to 32px for larger faces.
  • Placement: sidebar card, community page hero area, or a footer strip.

<div id="discord-widget" class="p-3 rounded shadow-sm text-center bg-dark text-light">
  <h5 class="mb-1">Join Our Community</h5>
  <p id="discord-online" class="text-secondary mb-3">Loading...</p>
  <div id="discord-avatars" class="d-flex justify-content-center flex-wrap gap-2 my-3"></div>
  <a href="https://discord.gg/YOUR_INVITE" class="btn btn-light">
    <i class="bi bi-discord me-1"></i> Join Now
  </a>
</div>

You’re All Set!

Your site now displays a live Discord online users widget. It shows real-time activity and makes joining effortless, ideal for gaming communities, support groups, and creator networks. Customize the design, reuse it across pages, and keep the Server Widget enabled for automatic updates.

FAQ

Yes, Discord’s JSON endpoint returns live presence data. The widget updates each time the page loads (you can also add interval polling if needed).

Yes, control invite settings in Discord. You can use temporary invites, permissions, or landing channels to manage new members.

Absolutely. The layout uses Bootstrap responsive utilities, so avatars and the button adapt to smaller screens.

Comments (3)

ME
MethodMan June 30, 2025 13:05

Works like a charm <3 thank you very much.

AL
AlaskaJoe July 1, 2025 12:03

One thing that is missing from the article is that bootstrap is not mentioned and the html is built using bootstrap. Other than that it works flawlessly. Thank You !

M.
M.Maxim July 1, 2025 12:05

Yes I was missing to mention the bootstrap but the widget can be styled in any way :D rest of the code is pretty much self explanatory and plug and play.

PE
Pete July 3, 2025 20:20

I'm seeing an 'Unable to load status' at the top of the widget - though the active users are indeed appearing. Is there something I'm missing? Also is there a way to limit the users shown, since a large Discord would result in hundreds of avatars being displayed?

M.
M.Maxim July 4, 2025 10:34

Unable to load status means the API may not be active. When it comes to limiting the amount of users you can limit in the loop when you are appending the users to the list. I'll make a video tutorial as well.

Leave a Comment

Replying to someone. Cancel