How to use an entire json file in the ‘secrets’ app settings when deploying on the community cloud?

Hi everyone,

I couldn’t find clear documentation on handling JSON service account files for secrets management in Streamlit Community Cloud deployments. Since this is a common need, I want to share the working solution I found using TOML:

Problem: Streamlit Cloud’s secrets management relies on TOML format, but service accounts often provide credentials as JSON.


  1. Manual Conversion:
  • Choose a section name in your secrets.toml file for example
  • Remove curly braces {} from your JSON.
  • Convert commas to newlines.( Remove Commas after each key value pair)
  • Replace JSON double quotes for keys with simple key names.
  • Use = instead of colons :.

Example secrets.toml:

type = "service_account"
project_id = "gen-lang-client-1234567"
private_key_id = "123467876656"
# ... other keys

  1. Accessing in Code:
import streamlit as st

google_credentials = st.secrets["GOOGLE_CREDENTIALS"] 
# Now use 'google_credentials' for authentication


  • Deployment: Place secrets.toml in your project’s root directory or use Streamlit Cloud’s UI for secrets.
  • Security: Never commit secrets.toml to public repositories.