An interactive environment to explore and experiment with the Common Expression Language (CEL) using JavaScript. Built with Next.js and powered by @marcbachmann/cel-js.
- Interactive CEL Evaluation: Write and test CEL expressions in real-time using
@marcbachmann/cel-js - Dynamic Version Loading: Load different CEL-JS versions on-demand via ESM
- Dual Format Support: Input variables in both JSON and YAML formats
- Auto-Format Detection: Automatically detects and validates JSON/YAML input
- Format Conversion: Easy switching between JSON and YAML with one-click conversion
- Safe Result Serialization: Handles BigInt and complex objects with
fast-json-stringify
- Pre-built Examples: Curated collection of CEL expressions with sample data
- Category Organization: Templates organized by use cases (Kubernetes, Istio, General, etc.)
- One-Click Loading: Select any template to instantly load expression and variables
- Default Template: Meaningful example loads automatically on first visit
- URL Sharing: Generate shareable URLs that encode your current playground state
- State Restoration: Open shared URLs to restore exact expression, variables, and version
- Clean URLs: Shared URLs automatically clean themselves after loading
- Real-time Updates: URLs update as you make changes for easy sharing
- Modern UI: Clean, responsive interface built with Next.js and Tailwind CSS
- Syntax Highlighting: Monospace fonts for better code readability
- Spell Check Disabled: No red underlines on CEL expressions or JSON/YAML
- Hover Cards: Interactive help and explanations
- Error Handling: Clear error messages and validation feedback
- Node.js 18+
- pnpm (recommended) or npm
-
Clone the repository
git clone https://github.com/SksOp/marc-cel-js-playground.git cd marc-cel-js-playground -
Install dependencies
pnpm install
-
Start the development server
pnpm dev
-
Open your browser Navigate to http://localhost:3000
- Select a CEL Version: Choose your preferred CEL-JS version from the dropdown
- Write Expression: Enter your CEL expression in the left panel
- Define Variables: Add input data in JSON or YAML format in the right panel
- Evaluate: Click "Run" to see the result
- Browse Templates: Use the template selector in the expression editor
- Load Example: Select any template to load expression and sample data
- Modify: Edit the loaded example to fit your needs
- Generate Share URL: Click the "Share" button to copy a shareable URL
- Share with Others: Send the URL to collaborators
- Open Shared URLs: Anyone can open your shared URL to see your exact setup
- JSON: Traditional object notation
{"key": "value"} - YAML: Human-readable format with proper indentation
- Auto-Detection: Automatically detects and validates your input format
- Conversion: Switch between formats with one-click buttons
cel-js-playground/
├── app/ # Next.js app directory
├── components/ # React components
│ ├── cel-* # CEL-specific components
│ └── ui/ # Reusable UI components
├── hooks/ # Custom React hooks
├── lib/ # Utility functions
├── package/ # CEL-related packages
│ ├── lib/ # Parser utilities
│ └── template/ # Template definitions
└── public/ # Static assets
- CelPlayground: Main playground component
- CelExpressionEditor: CEL expression input with template selector
- CelVariablesEditor: Variables input with JSON/YAML support
- CelTemplateSelector: Template selection dropdown
- ShareButton: URL generation and sharing functionality
- CelVersionSelector: CEL version selection
- Next.js 15: React framework with App Router
- TypeScript: Type-safe development
- Tailwind CSS: Utility-first CSS framework
- Radix UI: Accessible component primitives
- @marcbachmann/cel-js: JavaScript implementation of CEL
- js-yaml: YAML parsing and generation
- fast-json-stringify: High-performance JSON serialization
- ESM.sh: Dynamic module loading for CEL versions
# Development server
pnpm dev
# Build for production
pnpm build
# Start production server
pnpm start
# Type checking
pnpm type-checkTemplates are defined in package/template/template.ts. To add a new template:
{
name: 'Your Template Name',
cel: 'your CEL expression here',
dataInput: 'your sample data in YAML or JSON',
category: 'Category Name'
}- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- CEL Specification - Common Expression Language specification
- @marcbachmann/cel-js - High-performance JavaScript implementation of CEL with advanced features
- Next.js - React framework
- Tailwind CSS - CSS framework
- ESM.sh - ES modules CDN for dynamic loading