How to remove custom CSS from Confluence via the database
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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
Summary
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 making any database modifications. 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):
1
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
1
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:
1
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:
1
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:
1
select * from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%' and BANDANACONTEXT='_GLOBAL';
Run the following query to delete any custom Global Stylesheets:
1
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:
1
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.
1
select * from BANDANA where BANDANAKEY like '%atlassian.confluence.css.resource.custom%' and BANDANACONTEXT='<spacekey>' AND BANDANAVALUE !='<null/>'
Was this helpful?