JKConfig
A beautiful Terminal User Interface (TUI) configuration editor powered by JSON Schema. JKConfig automatically generates interactive forms from JSON Schema definitions, making configuration management intuitive and error-free.

Define your config in Rust → Generate JSON Schema → Edit with beautiful TUI
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Rust Structs │ │ JSON Schema │ │ Beautiful │
│ + schemars │ ──▶ │ (Auto-gen) │ ──▶ │ TUI Editor │
│ (#[derive]) │ │ config.schema │ │ (jkconfig) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │
│ ▼
│ ┌─────────────────┐
└──────────────────────────────────────▶ │ Config File │
Load & Use │ .toml / .json │
└─────────────────┘
✨ Features
- 🎨 Beautiful TUI Interface - Modern, responsive terminal UI built with Ratatui
- 📋 JSON Schema Driven - Automatically generates UI from JSON Schema (Draft 2020-12)
- 🔧 Multiple Data Types - Support for String, Integer, Number, Boolean, Enum, Array, Object, and OneOf
- 💾 Multi-Format Support - Read/write TOML and JSON configuration files
- ⌨️ Keyboard Shortcuts - Efficient navigation with Vim-like keybindings
- 🎯 Type Validation - Real-time validation based on schema constraints
- 🔄 Auto Backup - Automatic backup before saving changes
- 📚 Nested Structures - Handle complex nested objects and arrays
- 🌈 Color-Coded UI - Visual indicators for different data types and states
🤔 Why JKConfig?
Traditional Approach
// ❌ Manual config editing - error prone
// Edit raw TOML/JSON → Easy to make mistakes → Runtime errors
JKConfig Approach
// ✅ Type-safe from Rust to UI
// Define in Rust → Generate Schema → Edit with TUI → Load with confidence
Benefits:
- 🛡️ Type Safety: Your Rust types define the schema, ensuring consistency
- 🎨 User Friendly: Non-developers can edit configs with a beautiful interface
- ⚡ Fast: No more hunting through docs to understand config structure
- 🔍 Discoverable: Built-in help and descriptions for every field
- 🚀 Productive: Keyboard shortcuts for power users
Perfect for:
- 🔧 CLI tools that need user configuration
- 🏗️ Build systems (like ostool!)
- 🎮 Game server configurations
- 🔌 Plugin systems
- 📦 Any Rust project with complex configuration needs
📦 Installation
From Crates.io
From Source
🚀 Quick Start
The recommended workflow is to define your configuration structure in Rust and generate the JSON Schema automatically.
1. Define Your Config Structure in Rust
Add dependencies to your Cargo.toml:
[]
= { = "1.0", = ["derive"] }
= { = "1.0", = ["derive"] }
Create your configuration structure:
use ;
use ;
Run to generate the schema:
# Output: config-schema.json created
2. (Optional) Create Initial Configuration
Create config.toml:
[]
= "localhost"
= 8080
= true
= ["logging", "metrics", "auth"]
3. Launch JKConfig TUI
# Edit config.toml with the generated schema
# Or let it auto-detect (looks for config-schema.json)
Now you have a beautiful TUI to edit your configuration! 🎉
Alternative: Direct JSON Schema
If you prefer writing JSON Schema directly:
Create config-schema.json:
🎮 Usage
Command Line Options
)
Keyboard Shortcuts
Navigation
↑/↓orj/k- Move cursor up/downEnter- Select/Edit itemEsc- Go back to previous menu
Actions
C- Clear current valueM- Toggle menu state (for optional menus)Tab- Switch OneOf variants
Global
S- Save and exitQ- Quit without saving~- Toggle debug console
Array Editor
Enter- Add new item or edit selected itemDel- Delete selected itemEsc- Close array editor
📖 Supported JSON Schema Features
Data Types
| Type | Description | Example |
|---|---|---|
string |
Text input | "hostname" |
integer |
Whole numbers | 8080 |
number |
Decimal numbers | 3.14 |
boolean |
True/false toggle | true |
enum |
Selection list | ["option1", "option2"] |
array |
List of items | ["item1", "item2"] |
object |
Nested structure | {"key": "value"} |
Advanced Features
- OneOf - Select one variant from multiple schemas
- AnyOf - Flexible variant selection
- $ref - Schema references and reuse
- $defs - Schema definitions
- required - Mark fields as mandatory
- description - Display help text
- default - Default values
🎨 UI Components
Type Icons
- 📂 Menu/Object
- 🔀 OneOf variant
- 🔡 String
- 🔢 Integer/Number
- ✅/❎ Boolean
- 📚 Enum
- 📋 Array
🔧 Configuration File Formats
JKConfig supports both TOML and JSON formats:
TOML (Recommended)
[]
= "localhost"
= 8080
= ["feature1", "feature2"]
JSON
🛠️ Advanced Usage
Schema Auto-Detection
If you don't specify a schema file, JKConfig will automatically look for:
<config-name>-schema.json
Example:
- Config:
app.toml→ Schema:app-schema.json - Config:
config.json→ Schema:config-schema.json
Backup System
JKConfig automatically creates backups before saving:
- Format:
bk-<timestamp>.<ext> - Example:
bk-1698765432.toml
Complex Schemas
JKConfig handles complex nested structures:
🤝 Integration
Complete Workflow Example
Here's a complete example showing the recommended workflow from Rust structs to TUI editing:
// config_types.rs
use ;
use ;
Load Configuration in Your App
use Deserialize;
Use JKConfig as a Library
You can also use JKConfig programmatically in your Rust code:
use AppData;
// Load configuration programmatically
let app_data = new?;
// Access the configuration tree
println!;
// Get as JSON for further processing
let json_value = app_data.root.as_json;
Advanced: Complex Enum Types
JKConfig supports complex enum types (OneOf in JSON Schema):
use ;
use ;
In the TUI, you can use Tab to switch between different database types!
📝 Examples
See the tests/ directory for complete examples:
- Basic object structures
- Enum and OneOf variants
- Nested configurations
- Array handling
💡 Best Practices
1. Document Your Schema
Use doc comments in your Rust structs - they become descriptions in the UI:
2. Provide Sensible Defaults
3. Use Enums for Fixed Choices
4. Organize Complex Configs
// ✅ Good: Organized in modules
// ❌ Avoid: Flat structure with many fields
5. Version Your Schemas
6. Integrate into Your Build Process
Add a build.rs:
// build.rs
use schema_for;
7. Provide a Config Command
use Parser;
🐛 Troubleshooting
Schema not found
Error: Schema file does not exist: config-schema.json
Solution: Ensure your schema file exists and the path is correct.
Unsupported file format
Error: Unsupported config file extension: "yaml"
Solution: Use .toml or .json extensions.
Invalid schema
Error: Schema conversion error at path...
Solution: Validate your JSON Schema using JSON Schema Validator
🔄 Comparison with Similar Tools
| Feature | JKConfig | Other Config Editors |
|---|---|---|
| JSON Schema Support | ✅ Full | ⚠️ Limited |
| Terminal UI | ✅ Modern | ⚠️ Basic |
| Multiple Formats | ✅ TOML/JSON | ⚠️ Varies |
| Type Safety | ✅ Full | ❌ Manual |
| Auto Backup | ✅ Yes | ❌ No |
| Nested Structures | ✅ Full | ⚠️ Limited |
📚 Documentation
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
at your option.
👏 Acknowledgments
- Built with Ratatui TUI framework
- Inspired by Linux kernel's
menuconfig - JSON Schema validation and parsing
📧 Contact
- Author: 周睿 (Zhou Rui)
- Email: zrufo747@outlook.com
- Repository: https://github.com/ZR233/ostool
Made with ❤️ by the ostool team