How to remove custom CSS from Confluence via the database
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Purpose
If custom CSS has been added to Confluence and has broken page rendering, there is a chance it will need to be removed from the database instead of through the Confluence UI.
Solution
Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
Steps to remove custom CSS from a particular space
Stop Confluence
Confirm the space has CSS you need to remove via the following query (replace <spacekey> with the spacekey from the affected space):
select * from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%' and BANDANACONTEXT='<spacekey>';
Run the following query to delete any custom CSS associated with that space
delete from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%' and BANDANACONTEXT='<spacekey>';
- Start Confluence
Steps to remove custom CSS from all spaces
- Stop Confluence
Confirm that custom CSS stylesheets exist in any space with the following query:
select * from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%' and BANDANACONTEXT!='_GLOBAL';
Run the following query to delete all custom CSS stylesheets for any space:
delete from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%' and BANDANACONTEXT!='_GLOBAL';
Start Confluence
Steps to remove CSS from the Global Stylesheet
- Stop Confluence
Confirm there is a custom Global Stylesheet via the following query:
select * from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%' and BANDANACONTEXT='_GLOBAL';
Run the following query to delete any custom Global Stylesheets:
delete from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%' and BANDANACONTEXT='_GLOBAL';
Start Confluence
Steps to remove all custom CSS Stylesheets
- Stop Confluence
Run the following to delete any custom stylesheets:
delete from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%';
- Start Confluence
NOTE
When you modify a Custom CSS for a Space from UI and remove it completely (delete it) , its entry will be stored with <null> value in Database. The reason this value is still kept in DB is because when you modify a Custom CSS from UI and then remove it completely, you are technically editing it and not deleting it. Also, the button on UI says Edit and not Delete.
So if you want to pull the list of all Spaces which currently have Custom CSS and was deleted in past, you can run the below query to fetch those Spaces.
select * from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%' and BANDANACONTEXT='<spacekey>' AND BANDANAVALUE !='<null/>'