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

Bulk Delete Cloudflare DNS Records: Better Than Chrome Browser Console JavaScript

If you searched for a Chrome Browser Console JavaScript trick to bulk delete Cloudflare DNS, you are probably cleaning up a bad import, a rushed migration, or a zone that has drifted for years. The old approach of clicking dashboard buttons from DevTools depended on Cloudflare's front-end markup staying the same. That is not a safe operating model for a live DNS zone in 2026.

Cloudflare now gives you better first-party options: built-in bulk delete in the dashboard for one-off cleanup, and documented DNS APIs when you need something repeatable. For most teams, the real objective is not "delete faster." It is "remove the right records without breaking mail, domain verification, redirects, or production traffic."

Use the dashboard first for one-off cleanup

If this is a single-zone cleanup and the record list is manageable, start in Cloudflare's DNS Records page. Cloudflare's current bulk workflow lets you select records, choose Delete records, and then type DELETE to confirm. As of Cloudflare's current documentation, bulk DNS record changes are available on all plans, with limits of 200 records per action on Free and 3,500 on Pro, Business, and Enterprise.

That is a much better default than running browser-console JavaScript against changing CSS classes. It is visible, reviewable, and less likely to fail halfway through a live change.

  • Export the zone before you touch anything, so you have a rollback reference.
  • Review mail and verification records separately. MX, SPF, DKIM, DMARC, and vendor TXT records are common sources of accidental breakage.
  • Assign one owner for the cleanup. Bulk DNS edits go wrong fastest when three people are clicking around at once.

Use the API when the job must be repeatable

If you manage multiple client zones, want a reviewable runbook, or need to delete records by rule instead of by eyeballing them, use the Cloudflare API. Cloudflare's DNS delete endpoint requires DNS Write, and Cloudflare recommends API tokens over the older Global API Key. Even if your original instinct was JavaScript, the modern version of that idea is simple: script the API, not the dashboard DOM.

A practical pattern is to preview the records first, then run the delete. The example below lists records, filters them locally with jq, and prints a review table. That is safer than using fragile UI selectors. It also avoids relying on Cloudflare's free-text search parameter, which Cloudflare documents as human-oriented rather than automation-friendly.

export ZONE_ID=your_zone_id
export CLOUDFLARE_API_TOKEN=your_token

curl --silent "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records?per_page=50000" \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
| jq -r '.result[]
  | select(.type == "TXT" and (.name | endswith(".old.example.com")))
  | [.id, .type, .name, .content]
  | @tsv'

Once the preview looks right, change the filter only if needed and delete the matching record IDs:

curl --silent "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records?per_page=50000" \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
| jq -r '.result[]
  | select(.type == "TXT" and (.name | endswith(".old.example.com")))
  | .id' \
| while read -r id; do
    curl --silent --request DELETE \
      "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$id" \
      --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
    echo
  done

This follows the same official pattern Cloudflare documents for deleting all records, but scoped to a safer subset. For live zones, that scoped approach is usually the difference between controlled cleanup and self-inflicted outage.

If you need a change set, use batch operations

Cloudflare also supports batched DNS record changes via /dns_records/batch. That is useful when you want one reviewed payload instead of a loop of many individual requests. For deletes, only the record id is required in each object:

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

The operational nuance matters: Cloudflare executes the batch in one database transaction, but propagation across its network is not atomic. If you are deleting and replacing interdependent records during the same change window, treat it like a real release. Validate the final state, and do not assume every edge location sees every change at exactly the same moment.

Sometimes rebuilding the zone is smarter than deleting

If the zone is messy because of years of vendor changes or an over-eager quick scan, hundreds of tiny deletes may not be the smartest fix. Cloudflare supports exporting and importing BIND-style zone files. For larger restructures, exporting the zone, editing it offline, and re-importing a clean version can be more accurate than ad hoc deletion. Cloudflare's current import/export docs are also useful for limits: the zone file size limit is 256 KiB, and the import API rate limit is three requests per minute per user.

A practical workflow for live client zones

  1. Export the zone and keep the backup attached to the ticket or change record.
  2. Preview candidate deletes by type, name pattern, or content before you remove anything.
  3. Delete low-risk records first, then re-check web, email, and verification flows.
  4. If the zone needs many coordinated changes, prefer a reviewed batch payload or a rebuilt import file.
  5. Document what changed so the next agency, ops lead, or freelancer does not have to reverse-engineer the cleanup.

If you need to clean a live Cloudflare zone without guessing which records still support email, SaaS verification, or redirects, Greg can help turn the cleanup into a controlled change instead of a late-night console gamble.

Need help with this kind of work?

Talk to Greg about a safer DNS cleanup Get in touch with Greg.

Sources

  • Batch record changes · Cloudflare DNS docs
  • Delete all DNS records · Cloudflare DNS docs
  • List DNS Records | Cloudflare API
  • Delete DNS Record | Cloudflare API
  • Import and export records · Cloudflare DNS docs
Last modified
2026-05-01

Tags

  • Cloudflare
  • DNS
  • javascript
  • chrome console
  • api automation

Review Greg on Google

Greg Nowak Google Reviews

 

  • Bulk Delete Cloudflare DNS Records: Better Than Chrome Browser Console JavaScript
  • Search Console's Hourly Data Made Post-Launch SEO Monitoring an Ops Task
  • CodeIgniter Tips and Tricks for Secure Login and Password Resets
  • Drupal Commerce: Practical Setup and Scoping Guide
  • WP-CLI Tips and Tricks for Faster WordPress Operations
RSS feed

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