Skip to content

Instantly share code, notes, and snippets.

@LinkPhoenix
Created October 20, 2025 00:11
Show Gist options
  • Select an option

  • Save LinkPhoenix/b95ba22e5a4c28ce6b75b69962acf3a1 to your computer and use it in GitHub Desktop.

Select an option

Save LinkPhoenix/b95ba22e5a4c28ce6b75b69962acf3a1 to your computer and use it in GitHub Desktop.
Reset Brave Browser statistics (ads blocked, bandwidth saved) by editing the preferences JSON file.
<#
.SYNOPSIS
Reset Brave Browser usage statistics such as bandwidth saved and ads blocked.
.DESCRIPTION
This script reads Brave Browser’s preferences JSON file and resets user statistics (bandwidth and ad-block counters) to zero.
It was created and tested on Windows 11 Pro 25H2 to fix corrupted or inflated Brave stats values.
Brave must be completely closed before running this script, otherwise it will overwrite the changes upon exit.
No administrative privileges are required.
.PARAMETER None
No parameters required. The script runs interactively and confirms reset actions.
.EXAMPLE
.\Reset-BraveStats.ps1
Displays Brave statistics, asks for confirmation, resets values to zero, and verifies the update.
.NOTES
Created: 2025-10-20
Version: 1.0
#>
# Compose path in a portable way
$prefPath = Join-Path -Path $env:LOCALAPPDATA -ChildPath "BraveSoftware\Brave-Browser\User Data\Default\preferences"
if (-not (Test-Path $prefPath)) {
Write-Error "Preferences file not found: $prefPath"
exit 1
}
function Read-Stats {
param($path)
$json = Get-Content $path -Raw | ConvertFrom-Json
$stats = $json.brave.stats
return [PSCustomObject]@{
BandwidthSaved = [int64]$stats.bandwidth_saved_bytes
AdsBlocked = [int]$stats.ads_blocked
JsonObject = $json
}
}
function Write-Stats {
param($path, $jsonObj, $newBandwidth, $newAds)
# Update the JSON object properties directly
$jsonObj.brave.stats.bandwidth_saved_bytes = $newBandwidth
$jsonObj.brave.stats.ads_blocked = $newAds
# Convert object back to JSON with formatting
$jsonString = $jsonObj | ConvertTo-Json -Depth 10
# Write back to file
Set-Content -Path $path -Value $jsonString -Encoding UTF8
}
# Read initial stats and display
$stats = Read-Stats -path $prefPath
Write-Host ""
Write-Host "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓" -ForegroundColor Cyan
Write-Host "┃ Brave Browser Data Summary ┃" -ForegroundColor Green
Write-Host "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛" -ForegroundColor Cyan
Write-Host ("• Bandwidth saved : {0:N0} bytes" -f $stats.BandwidthSaved) -ForegroundColor Yellow
Write-Host ("• Trackers & ads blocked : {0:N0}" -f $stats.AdsBlocked) -ForegroundColor Yellow
Write-Host ""
# Ask user for reset confirmation
do {
$answer = Read-Host "Do you want to reset these values to 0? [Y/n]"
if ([string]::IsNullOrWhiteSpace($answer)) { $answer = 'y' }
$answer = $answer.ToLower()
} while ($answer -notin @('y', 'yes', 'n', 'no'))
if ($answer -in @('n', 'no')) {
Write-Host "No changes made. Exiting." -ForegroundColor DarkGray
exit 0
}
# Write zeros and verify
Write-Stats -path $prefPath -jsonObj $stats.JsonObject -newBandwidth 0 -newAds 0
# Reload to confirm
$updatedStats = Read-Stats -path $prefPath
Write-Host ""
Write-Host "Values have been reset." -ForegroundColor Green
Write-Host ("• Bandwidth saved : {0:N0} bytes" -f $updatedStats.BandwidthSaved) -ForegroundColor Yellow
Write-Host ("• Trackers & ads blocked : {0:N0}" -f $updatedStats.AdsBlocked) -ForegroundColor Yellow
Write-Host ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment