Cloudflare Docs
DNS
DNS
Edit this page on GitHub
Set theme to dark (⇧+D)

Delete all DNS records

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 delete all DNS records, follow the steps below. This method assumes you are familiar with API calls fundamentals.

  1. Make sure you have an API token that allows you to edit DNS for your zone.
  2. Get your zone ID.
  3. Run the following script, replacing <ZONE_ID> and <API_TOKEN> with the values you got from the previous steps.
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