If you have curated a list of domain blocks on your Mastodon account, you may want to export that list to back it up or transfer it to another instance. Mastodon does not offer a single-click export for per user domain blocks through the web interface. This article explains where domain block data is stored, how to extract it using the Mastodon API, and how to save the list as a portable backup file.
Key Takeaways: Exporting Domain Blocks from Mastodon
- Preferences > Import and Export > Export: The web interface exports posts, lists, and follows but does not export domain blocks.
- API endpoint /api/v1/domain_blocks: Returns a JSON array of all domains you have blocked on your account.
- Manual backup via cURL or browser developer tools: The only reliable method to capture the full list of blocked domains.
Why Domain Blocks Are Not Included in Standard Mastodon Exports
Mastodon provides an export tool under Preferences > Import and Export > Export. This tool generates CSV and JSON files for your posts, media attachments, lists, follows, and mutes. Domain blocks are intentionally excluded from this export set. The Mastodon development team considers domain blocks a per user preference tied to the account’s moderation state. They are not part of the portable data format used when moving accounts between instances.
Domain blocks are stored in the database as a separate association on the user record. The standard export API endpoint (/api/v1/export) does not include a method for domain blocks. To retrieve them, you must call the same API endpoint that the web client uses when you view or manage your blocked domains.
How to Export Domain Blocks Using the Mastodon API
You can export your domain blocks by making a GET request to /api/v1/domain_blocks. This endpoint returns a JSON array of strings, each string being a domain name you have blocked. You need an access token with the read:blocks scope. The following steps assume you are using a Mastodon instance that supports OAuth tokens.
- Generate an access token with the read:blocks scope
Go to Preferences > Development > New Application. Name the application something like “Domain Block Backup”. Under Scopes, select onlyread:blocks. Save the application and copy the access token string. - Open a terminal or command prompt
On Windows, press Win + R, typecmd, and press Enter. On macOS or Linux, open the Terminal app. - Run the cURL command to fetch domain blocks
Type the following command, replacingyour.instance.socialwith your Mastodon instance domain andYOUR_TOKENwith the access token from step 1:curl -H "Authorization: Bearer YOUR_TOKEN" https://your.instance.social/api/v1/domain_blocks
Press Enter. The response will be a JSON array, for example:["badspam.example","malware.example.org"]. - Save the output to a file
Run the command again, appending> domain_blocks_backup.jsonto the end. Example:curl -H "Authorization: Bearer YOUR_TOKEN" https://your.instance.social/api/v1/domain_blocks > domain_blocks_backup.json
This saves the JSON array to a file named domain_blocks_backup.json in the current directory.
Alternative Method: Using Browser Developer Tools
If you prefer not to use cURL, you can capture the domain block list directly from the Mastodon web interface.
- Log in to your Mastodon instance in a browser
Open your instance in Chrome, Firefox, or Edge. - Open Developer Tools
Press F12 or Ctrl + Shift + I. Go to the Network tab. - Navigate to your domain blocks page
Go to Preferences > Moderation > Domain Blocks. The page may show a list of blocked domains. - Locate the API request for domain_blocks
In the Network tab, look for a request to/api/v1/domain_blocks. Click on it and view the Response tab. Copy the JSON array. - Save the data to a text file
Open Notepad or any text editor. Paste the JSON array. Save the file asdomain_blocks_backup.json.
Common Mistakes and Limitations When Exporting Domain Blocks
Access Token Does Not Have the Correct Scope
If the cURL command returns 403 Forbidden, the token does not have the read:blocks scope. Generate a new application with only that scope selected. Revoke any tokens with excessive scopes to maintain security.
Domain Blocks Are Not Exported When Moving Accounts
When you use Preferences > Account > Move to a different account, Mastodon transfers followers, follows, lists, and mutes. Domain blocks are not part of that migration. After moving, you must manually reapply your domain blocks on the new account. Use the export file you created earlier to add each domain back.
Export File Format Is JSON, Not CSV
The API returns a plain JSON array. If you need CSV format, you can convert the file using any online JSON-to-CSV converter or a short script. For example, in Python, you can read the JSON file and write each domain to a CSV row.
Mastodon Export Options: Web Interface vs API
| Item | Web Interface Export | API Export |
|---|---|---|
| Posts | CSV and JSON | JSON via /api/v1/export |
| Follows | CSV | JSON via /api/v1/export |
| Lists | CSV | JSON via /api/v1/export |
| Mutes | CSV | JSON via /api/v1/export |
| Domain Blocks | Not available | JSON via /api/v1/domain_blocks |
The web interface export covers most user data but omits domain blocks. The API method is the only way to retrieve them. Keep the JSON file in a secure location because it reveals which domains you have blocked.
After exporting, you can import the domain block list into another account by making POST requests to /api/v1/domain_blocks with each domain. You need a token with the write:blocks scope. For each domain, send a POST request with the body {"domain":"example.com"}. This restores your block list on the new account.