Skip to main content
GrN.dk

Main navigation

  • Articles
  • Contact
  • Your Digital Project Manager
  • About Greg Nowak
  • Services
  • Portfolio
  • Container
    • Excel Freelancer
    • Kubuntu - tips and tricks
    • Linux Apache MySQL and PHP
    • News
    • Image Gallery
User account menu
  • Log in

Breadcrumb

  1. Home

How to Bulk Delete Cloudflare DNS Records Without Browser Console JavaScript

By Greg Nowak. Last updated 2026-07-11.

If you are looking for browser-console JavaScript to bulk-delete Cloudflare DNS records, you probably have a cleanup problem rather than a JavaScript problem: an untidy import, a completed migration, or years of records left behind by former vendors.

Running a click-loop in DevTools used to feel like the quickest answer. It was also brittle. A dashboard update could break the script halfway through, while an overly broad selector could remove records you never intended to touch. Cloudflare now provides first-party bulk operations in its dashboard and API. The safer question is therefore not “How can I click Delete faster?” but “Which workflow gives us a reviewable change and a credible recovery path?”

Choose the right cleanup method

Situation Best method Why
One zone with an obvious selection Dashboard bulk delete Fast, visible, and easy for a colleague to review
Records match a clear rule List and delete through the API Repeatable filtering with an explicit preview
Deletes and replacements belong together Batch API One reviewed request containing the complete change set
The zone needs extensive reconstruction Export, edit, and import A before-and-after file is often clearer than hundreds of individual actions
A practical decision matrix for Cloudflare DNS cleanup.

Use dashboard bulk delete for straightforward jobs

On the DNS Records page, select the records, choose Delete records, and type DELETE when prompted. As of July 2026, Cloudflare makes this available on every plan. One action can include up to 200 records on Free zones and 3,500 on Pro, Business, and Enterprise zones.

This is usually the best option when a human can confidently identify the records. Before confirming, export the zone and save the file with the change ticket. Treat that export as recovery material, not a magic Undo button: restoration still needs to be checked carefully.

Review these records separately before any broad deletion:

  • MX, SPF, DKIM, and DMARC records that protect email delivery;
  • TXT records used for domain ownership or SaaS verification;
  • CAA, SRV, and delegated NS records;
  • records supporting customer logins, redirects, certificates, or migration fallbacks.

For repeatable cleanup, preview through the API

Use a narrowly scoped API token with DNS Read for discovery and DNS Write only when deletion is required. Cloudflare recommends API tokens instead of the older Global API Key.

The list endpoint supports structured filters for type, name, content, tags, and comments. Avoid building automation around its free-text search parameter: Cloudflare explicitly reserves that feature for human use and may change its behaviour.

The following example downloads a snapshot, checks that Cloudflare reported success, and creates a reviewable list of matching TXT records. Replace the example domain and selection rule before running it:

export ZONE_ID="your_zone_id"
export CLOUDFLARE_API_TOKEN="your_token"

curl --fail-with-body --silent --show-error \
  "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records?per_page=50000" \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  > dns-records.json

jq -e '.success == true' dns-records.json > /dev/null

jq -r '.result[]
  | select(
      .type == "TXT" and
      (.name == "old.example.com" or
       (.name | endswith(".old.example.com")))
    )
  | [.id, .type, .name, .content]
  | @tsv' dns-records.json > candidates.tsv

wc -l candidates.tsv
column -t -s $'\t' candidates.tsv

Stop here and inspect candidates.tsv. Confirm the count, names, values, and business purpose with whoever owns the affected service. For zones exceeding the requested page size, process every page reported in result_info.total_pages; never assume that one response contains the whole zone.

Delete only the reviewed record IDs

Once the candidate file has been approved, feed its first column to the documented delete endpoint:

cut -f1 candidates.tsv > approved-record-ids.txt

while IFS= read -r id; do
  curl --fail-with-body --silent --show-error \
    --request DELETE \
    "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$id" \
    --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
  echo
done < approved-record-ids.txt

Keeping discovery and deletion as separate steps is intentional. It produces an approval artifact, prevents a changing query from silently expanding the deletion, and makes the operation easier to audit. Do not place long-lived tokens in source control, shared chat, or shell scripts committed to a repository.

Use the batch endpoint for coordinated changes

If records must be deleted and replaced during the same change window, Cloudflare’s /dns_records/batch endpoint can carry deletes, patches, puts, and posts in one request. Operations run in that order. A minimal deletion body looks like this:

{
  "deletes": [
    { "id": "RECORD_ID_1" },
    { "id": "RECORD_ID_2" }
  ]
}

Cloudflare executes a batch as one database transaction, but propagation across its distributed network is not atomic. Clients may briefly observe different stages of a coordinated change. Plan the sequence, retain old destinations where practical, and validate the finished state rather than assuming a successful API response proves the service works.

Finish with service-level checks

  1. List the zone again and confirm that only approved IDs disappeared.
  2. Resolve important names through more than one public DNS resolver.
  3. Test the website, redirects, email flow, certificate issuance, and vendor verification affected by the change.
  4. Record what was removed, who approved it, and where the export and candidate list are stored.

For a deeply cluttered zone, rebuilding from a reviewed export may be clearer than running hundreds of deletes. Cloudflare currently limits imported zone files to 256 KiB and the import API to three requests per minute per user, so include those constraints in the plan.

If your zone supports revenue, email, or customer access and nobody is entirely sure which records are still needed, Greg can help turn the cleanup into a controlled DNS change with clear ownership, review, and validation.

Related on GrN.dk

  • AI automations need a spend dashboard before the first runaway bill
  • When AI writes JSON, one bad field can break the workflow
  • AI search is eating the click: measure the queries before rewriting pages

Need help with this kind of work?

Plan a safer DNS cleanup with Greg Get in touch with Greg.

Sources

  • Batch record changes · Cloudflare DNS docs
  • List DNS Records · Cloudflare API
  • Delete DNS Record · Cloudflare API
  • Import and export records · Cloudflare DNS docs
Last modified
2026-07-11

Tags

  • Cloudflare
  • DNS
  • DNS cleanup
  • Cloudflare API
  • Operations

Review Greg on Google

Greg Nowak Google Reviews

 

Hand-drawn sketch infographic summarizing: WordPress Speculative Loading Needs a Cart, Analytics, and Cache Test
WordPress Speculative Loading Needs a Cart, Analytics, and Cache Test
2026-06-24

WordPress 6.8 adds cautious speculative loading. Before enabling stronger prerendering, test cart state, analytics, personalization, and cache load.

Hand-drawn sketch infographic summarizing: ChatGPT Is Becoming Office Software: Put Admin Hygiene First
ChatGPT Is Becoming Office Software: Put Admin Hygiene First
2026-06-24

ChatGPT now has files, sessions, apps, and scheduled work. Treat it like office software: audit access, clean up retained data, and limit risk.

Hand-drawn sketch infographic summarizing: Search Console Can See Social Posts—Your Reports Need a New Map
Search Console Can See Social Posts—Your Reports Need a New Map
2026-07-13

Search Console now reports how social posts perform across Google. Here’s a practical way to manage properties, permissions, baselines and exports.

Hand-drawn sketch infographic summarizing: WordPress Now Speaks AI; Plugins Still Need Real Guardrails
WordPress 7.0 Has an AI Client. Plugins Need Their Own Guardrails
2026-07-12

WordPress 7.0 standardizes how plugins call AI providers, while leaving developers responsible for access control, cost limits, capability checks and graceful failures.

Hand-drawn sketch infographic summarizing: AI images need a media-library audit before they reach clients
AI images need a media-library audit before they reach clients
2026-06-24

AI-generated images can carry provenance signals, but CMS resizing, plugins, and CDNs may change them. Audit the media path before delivery.

Hand-drawn sketch infographic summarizing: AI disclosure rules belong in the CMS, not a spreadsheet
AI disclosure rules belong in the CMS, not a spreadsheet
2026-06-26

AI-assisted publishing needs visible disclosure choices, review evidence, and SEO checks inside the CMS, not in a side spreadsheet.

Hand-drawn sketch infographic summarizing: The risky part of AI workflow pilots is often the OAuth screen
The risky part of AI workflow pilots is often the OAuth screen
2026-06-26

AI workflow pilots can fail at the access layer. Review OAuth scopes, API keys, service accounts, and revocation paths before launch.

Hand-drawn sketch infographic summarizing: AI crawler permissions now belong in a licensing register
AI crawler permissions now belong in a licensing register
2026-06-27

AI crawler controls now affect search visibility, AI answers, model training, and licensing. A register keeps policy, evidence, and enforcement aligned.

Hand-drawn sketch infographic summarizing: Google’s AI Search toggle needs a test plan, not a gut decision
Google’s AI Search toggle needs a test plan, not a gut decision
2026-07-11

Google’s AI Search control creates a measurable publishing choice. Test visibility, traffic and leads before changing the setting across your site.

Hand-drawn sketch infographic summarizing: WordPress headless menus need an exposure check before launch
WordPress headless menus need an exposure check before launch
2026-06-28

WordPress 6.8 helps headless builds expose menu data through the REST API, but agencies should review exactly what becomes public before launch.

More articles
RSS feed

GrN.dk web platforms, web optimization, data analysis, data handling and logistics.