Unfortunately, there is no SharePoint out of the box feature for backup/versioning of SharePoint JSON formatting.
However, if you want to backup the JSON formatting codes locally, you can do it using the PnP PowerShell.
Below is the sample script which backups the column, view and form formatting JSON in SharePoint site. This script is directly taken from the script sample at (Thanks to Dan Toft): Extract all custom formatting
function get-customFormatting() {
$url = Read-Host -Prompt "Enter the URL of the site you wish to backup custom formatting from"
Connect-PnPOnline $url -Interactive
try {
$web = Get-PnPWeb -Includes Title
}
catch {
Write-Host "Please connect to a site first" -Color Red
return;
}
Write-Host "Backing up formatting for '$($web.Title)', fetching lists";
$lists = Get-PnPList -Includes Id, Title, Views, Fields, ContentTypes | Where-Object { -not $_.Hidden }
Write-Host "Fetched data - starting backup";
foreach ($list in $lists) {
$fields = $list.Fields | Where-Object { $_.CustomFormatter -ne $null -and $_.CustomFormatter -ne "" }
foreach ($field in $fields) {
try {
Write-Host "List '$($list.Title)' > field: '$($field.Title)'";
New-Item -Path "CustomFormatting\$($list.Title)\Columns\" -Name "$($field.Title) ($($field.InternalName)).column-formatter.json" -ItemType File -Value $($field.CustomFormatter | ConvertFrom-Json | ConvertTo-Json -Depth 100) -Force | Out-Null;
}
catch {
Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red;
}
}
$views = $list.Views | Where-Object { $_.CustomFormatter -ne $null -and $_.CustomFormatter -ne "" }
foreach ($view in $views) {
try {
Write-Host "List '$($list.Title)' > `View: '$($view.Title)'";
New-Item -Path "CustomFormatting\$($list.Title)\Views\" -Name "$($view.Title).view-formatter.json" -ItemType File -Value $($view.CustomFormatter | ConvertFrom-Json | ConvertTo-Json -Depth 100) -Force | Out-Null;
}
catch {
Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red;
}
}
$formCustomizer = $list.ContentTypes | Where-Object { $_.ClientFormCustomFormatter -ne $null -and $_.ClientFormCustomFormatter -ne "" }
foreach ($form in $formCustomizer) {
try {
Write-Host "List '$($list.Title)' > form: '$($form.Name)'";
New-Item -Path "CustomFormatting\$($list.Title)\Forms\" -Name "$($form.Name).form-formatter.json" -ItemType File -Value $($form.ClientFormCustomFormatter | ConvertFrom-Json | ConvertTo-Json -Depth 100) -Force | Out-Null;
}
catch {
Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red;
}
}
}
}
get-customFormatting;