Delete all DNS records
Last updated Apr 16, 2026 When you connect your domain to Cloudflare, the DNS records quick scan may automatically add several records to your zone.
If you realize most of them are not applicable and want to bulk delete DNS records, follow the steps below. This method assumes you are familiar with API calls fundamentals.
Bulk deletion available in the dashboard
You can delete records in bulk via the dashboard, which removes the need for custom scripts as the one below. Refer to Batch record changes for details.
- Make sure you have an API token that allows you to edit DNS for your zone.
- Get your zone ID.
- Run the following script, replacing
<ZONE_ID>and<API_TOKEN>with the values you got from the previous steps.
Warning
This script uses jq ↗︎ to format JSON outputs for readability. Refer to Make API calls for details.
zoneid=<ZONE_ID>
bearer=<API_TOKEN>
curl --silent "https://api.cloudflare.com/client/v4/zones/$zoneid/dns_records?per_page=50000" \
--header "Authorization: Bearer $bearer" \
| jq --raw-output '.result[].id' | while read id
do
curl --silent --request DELETE "https://api.cloudflare.com/client/v4/zones/$zoneid/dns_records/$id" \
--header "Authorization: Bearer $bearer"
done
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/dns/zone-setups/troubleshooting/delete-all-records/#page","headline":"Delete all DNS records","description":"Learn how to bulk delete DNS records in Cloudflare with a script so you can start from zero instead of using the quick scan results.","url":"https://developers.cloudflare.com/dns/zone-setups/troubleshooting/delete-all-records/","inLanguage":"en","image":"https://developers.cloudflare.com/dns/zone-setups/troubleshooting/delete-all-records/og.png?v=a0db5eada4adba3e","dateModified":"2026-04-16","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Learn why a domain may be removed from Cloudflare and how to recover it using audit logs and registrar verification. title: Domain deleted from Cloudflare image: https://developers.cloudflare.com/dns/zone-setups/troubleshooting/domain-deleted/og.png?v=a74dff9c92f62533
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/dns/llms.txt
Use this file to discover all available pages before exploring further.
Docs