CLI tool to export a Discord server's structure to a JSON template and import it into a blank server.
- Server settings (name, icon, verification level, notification defaults, content filter, AFK channel/timeout, system channel)
- Roles (name, permissions, color, hoist, mentionable, position)
- Categories with permission overwrites
- Text, voice, news, forum, and stage channels with permission overwrites
- Channel properties (topic, NSFW, slowmode, bitrate, user limit)
Permission overwrites are stored by role name so templates are portable across servers.
pip install .After installing, the discord-template command is available. You can also run it as a module:
python -m discord_template --helpThere are two ways to authenticate for export (choose one):
Option A: User token (no bot needed)
Export uses read-only REST calls, so your own Discord user token works without creating a bot. To get your token:
- Open Discord in a browser and press F12 to open DevTools
- Go to the Network tab, then send any message or switch channels
- Click a request to
discord.com, find theAuthorizationheader in the request headers - Copy that value
export DISCORD_USER_TOKEN="your-user-token-here"Option B: Bot token
- Go to https://discord.com/developers/applications and create a new application
- Go to the Bot tab and click Reset Token to get your bot token
- Under Privileged Gateway Intents, enable Server Members Intent
- Go to OAuth2 > URL Generator, select the
botscope, and grant Administrator permission - Use the generated URL to invite the bot to both your source and target servers
export DISCORD_BOT_TOKEN="your-bot-token-here"A bot token is required for the import command since it makes write operations.
discord-template export --user-token "$DISCORD_USER_TOKEN" --guild-id 123456789 -o my-server.jsondiscord-template export --token "$DISCORD_BOT_TOKEN" --guild-id 123456789 -o my-server.jsonIf someone has shared a discord.new template link, you can convert it directly with no authentication:
discord-template fetch "https://discord.new/aBcDeFgH" -o my-server.jsonYou can also pass just the bare code:
discord-template fetch aBcDeFgH -o my-server.jsonNative Discord templates include roles and channel structure but may lack some details (topics, NSFW flags, per-channel overwrites) compared to a full export.
discord-template inspect -t my-server.jsondiscord-template import --guild-id 987654321 -t my-server.jsonThe import command runs safety checks to ensure the target server is blank:
- At most 1 text channel (the auto-created default)
- No voice channels or categories
- No custom roles (only @everyone)
- No custom emoji or stickers
- Bot has Administrator permission
Use --dry-run to preview what would be created without making changes:
discord-template import --guild-id 987654321 -t my-server.json --dry-runUse --force to bypass safety checks (you will still be prompted to confirm):
discord-template import --guild-id 987654321 -t my-server.json --forceUse --keep-defaults to preserve the server's original default channels instead of deleting them after import:
discord-template import --guild-id 987654321 -t my-server.json --keep-defaults- Enable Developer Mode in Discord: User Settings > App Settings > Advanced > Developer Mode
- Right-click the server name and select Copy Server ID
Running import twice on the same server will not create duplicates. Existing roles are matched by name and updated in place, and existing channels are matched by name, type, and parent category. Only new entries are created. The --dry-run output shows [create] or [update] next to each item so you can see what will happen.
- Messages, members, bans, webhooks, and integrations are not copied
- Custom emoji and stickers are not copied
- The bot can only reorder roles below its own highest role