1212  MQTT Topic Designer

Interactive Tool for Designing and Validating MQTT Topic Hierarchies

animation
mqtt
iot
messaging
protocols

1212.1 MQTT Topic Designer

Design and validate your MQTT topic hierarchies with best practices feedback. This interactive tool helps you create well-structured, scalable, and efficient topic patterns for your IoT deployments.

NoteTool Overview

This comprehensive topic design tool provides:

  • Topic Pattern Input: Design topic hierarchies with variables
  • Linting Rules: 12 best practice checks with detailed feedback
  • Wildcard Tester: Test subscription patterns against topics
  • Scale Projection: Calculate topic counts and subscription efficiency
  • Visual Tree: See your topic hierarchy visualized
  • Example Generator: Generate sample topics from patterns
TipHow to Use This Tool
  1. Enter a topic pattern using {variable} syntax for placeholders
  2. Review the lint results for best practice compliance
  3. Test wildcard subscriptions to understand matching behavior
  4. Configure scale parameters to project deployment size
  5. Export your topic design for documentation

1212.2 How to Use This Tool

1212.2.1 Topic Pattern Syntax

Use curly braces {variable_name} to define placeholder variables in your topic pattern:

Pattern Element Description Example
Static text Fixed topic level v1, sensor, data
{variable} Placeholder for dynamic values {device_id}, {sensor_type}
/ Level separator Separates hierarchy levels

1212.2.2 Common Topic Patterns

# IoT Telemetry Pattern
v1/{org}/{site}/{device_id}/telemetry/{sensor_type}

# Command/Response Pattern
v1/{org}/device/{device_id}/command/request
v1/{org}/device/{device_id}/command/response

# Status Pattern
v1/{org}/device/{device_id}/status/{status_type}

# Event Pattern
v1/{org}/device/{device_id}/event/{event_type}

1212.2.3 Wildcard Usage

Wildcard Meaning Example
+ Matches exactly one level v1/+/device/# matches v1/acme/device/001/temp
# Matches zero or more levels (must be last) v1/org1/# matches all topics under v1/org1/

1212.3 Best Practices Reference

TipTopic Design Best Practices
  1. Use version prefixes (v1/, v2/) to enable API evolution without breaking clients
  2. Place identifiers early in the hierarchy for efficient wildcard filtering
  3. Keep depth reasonable (5-7 levels) to balance specificity and performance
  4. Use lowercase consistently to avoid case-sensitivity issues
  5. Include data type suffixes like /data, /status, /command, /event
  6. Avoid special characters and spaces in topic levels
  7. Plan for multi-tenancy with organization/tenant prefixes
  8. Consider message routing - place routing-relevant levels first
  9. Document your schema for team consistency
  10. Test with wildcards before deployment to ensure expected matching

1212.3.1 Topic Hierarchy Recommendations

Level Position Recommended Content Rationale
1 Version (v1, v2) API evolution without breaking
2 Organization/Tenant Multi-tenant isolation
3 Site/Location Geographic filtering
4 Device ID Per-device subscriptions
5 Data Category Sensor type or data type
6-7 Specifics Additional context as needed

1212.3.2 Anti-Patterns to Avoid

WarningCommon Mistakes
  • Starting with /: Creates an empty first level
  • Using spaces: Causes parsing issues
  • Deep hierarchies (8+ levels): Reduces performance
  • Using $: Reserved for broker system topics
  • Inconsistent casing: Leads to matching failures
  • Flat topics: Makes filtering impossible with wildcards

1212.4 What’s Next


This interactive tool is implemented in approximately 850 lines of Observable JavaScript. Key features:

  1. Topic pattern input: Design topics with variable placeholders
  2. 12 linting rules: Best practice validation with pass/fail/warning
  3. Wildcard tester: Test + and # subscription patterns
  4. Scale projection: Calculate topic counts and broker requirements
  5. Topic tree visualization: Hierarchical view of topic structure
  6. Example generator: Generate sample topics from patterns

The tool uses the IEEE color palette for consistency: - Navy (#2C3E50): Primary UI elements - Teal (#16A085): Good indicators, success states - Orange (#E67E22): Warnings - Red (#E74C3C): Errors - Purple (#9B59B6): Special highlights