Skip to main content

A Streamlit custom component for viewing JSON with interactive tooltips and tags

Project description

Streamlit JSON Tip

A Streamlit custom component for viewing JSON data with interactive tooltips and tags for individual fields.

Streamlit JSON Tip Example

Features

  • 🔍 Interactive JSON Viewer: Expand/collapse objects and arrays
  • 📝 Interactive Tooltips: Add contextual help for any field with professional Tippy.js tooltips
  • 🏷️ Field Tags: Categorize fields with colored tags (PII, CONFIG, etc.)
  • 🎯 Field Selection: Click on fields to get detailed information
  • 🎨 Syntax Highlighting: Color-coded JSON with proper formatting
  • 📱 Responsive Design: Works well in different screen sizes

Installation

From PyPI (Recommended)

pip install streamlit-json-tip

From TestPyPI (Latest Development Version)

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ streamlit-json-tip

Development Setup

  1. Clone this repository:

    git clone https://github.com/isaac/streamlit-json-tip.git
    cd streamlit-json-tip
    
  2. Set up development environment with uv:

    # Install uv if you haven't already
    curl -LsSf https://astral.sh/uv/install.sh | sh
    
    # Create virtual environment and install all dependencies (including dev dependencies)
    uv sync
    
  3. Run the example app:

    uv run streamlit run example_app.py
    

Usage

import streamlit as st
from streamlit_json_tip import json_viewer

# Your JSON data
data = {
    "user": {
        "id": 123,
        "name": "John Doe",
        "email": "john@example.com"
    }
}

# Help text for specific fields
help_text = {
    "user.id": "Unique user identifier",
    "user.name": "Full display name",
    "user.email": "Primary contact email"
}

# Tags for categorizing fields
tags = {
    "user.id": "ID",
    "user.name": "PII",
    "user.email": "PII"
}

# Display the JSON viewer
selected = json_viewer(
    data=data,
    help_text=help_text,
    tags=tags,
    height=400
)

# Handle field selection
if selected:
    st.write(f"Selected field: {selected['path']}")
    st.write(f"Value: {selected['value']}")
    if selected.get('help_text'):
        st.write(f"Help: {selected['help_text']}")

Parameters

  • data (dict): The JSON data to display
  • help_text (dict, optional): Dictionary mapping field paths to help text
  • tags (dict, optional): Dictionary mapping field paths to tags/labels
  • height (int, optional): Height of the component in pixels (default: 400)
  • key (str, optional): Unique key for the component

Field Path Format

Field paths use dot notation for objects and bracket notation for arrays:

  • "user.name" - Object field
  • "items[0].title" - Array item field
  • "settings.preferences.theme" - Nested object field

Development

Frontend Development

  1. Set up the development environment (see Development Setup above)

  2. Navigate to the frontend directory:

    cd streamlit_json_tip/frontend
    
  3. Install frontend dependencies:

    npm install
    
  4. Start development server:

    npm start
    
  5. In your Python code, set _RELEASE = False in __init__.py

  6. Run the example app in another terminal:

    uv run streamlit run example_app.py
    

Building for Production

  1. Build the frontend:

    cd streamlit_json_tip/frontend
    npm run build
    
  2. Set _RELEASE = True in __init__.py

  3. Build the Python package:

    uv run python -m build
    
  4. Upload to PyPI:

    uv run python -m twine upload dist/*
    

Build Scripts

The project includes convenient uv scripts for common development tasks:

Frontend Development

uv run build-frontend        # Build React frontend for production

Package Building

uv run clean                 # Clean build artifacts
uv run build                 # Clean + build Python package
uv run build-check           # Build + validate package with twine

Publishing

uv run publish-test          # Build + upload to TestPyPI
uv run publish               # Build + upload to PyPI

Complete Workflow

uv run release-test          # Build frontend + publish to TestPyPI
uv run release               # Build frontend + publish to PyPI (production)

For a complete release, simply run:

uv run release

This will build the frontend, package the Python distribution, validate it, and upload to PyPI.

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_json_tip-0.2.3.tar.gz (769.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_json_tip-0.2.3-py3-none-any.whl (654.1 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_json_tip-0.2.3.tar.gz.

File metadata

  • Download URL: streamlit_json_tip-0.2.3.tar.gz
  • Upload date:
  • Size: 769.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for streamlit_json_tip-0.2.3.tar.gz
Algorithm Hash digest
SHA256 75d748168a24c85b018b9dc42516ea89ce191bca5c6dcb452b131922c684d94c
MD5 8c2273a186c21613fb218ac583946e26
BLAKE2b-256 2e35340d400874d93f4ff6f446230757a72b7f656680d5511045cc4bd25fde9d

See more details on using hashes here.

File details

Details for the file streamlit_json_tip-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_json_tip-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e246fedc8a5e1a41b7f3eaa78bbfc332824f28cfd18c48c23eef49ad119d4655
MD5 7fd4c70237509a56b4da3948c984d266
BLAKE2b-256 9515e1925a54ed37d958383e3f4cb359189bc7f4626e69785e12a329e897a84f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page