• Townie
    AI
  • Blog
  • Docs
  • Pricing
Log inSign up
mattspieg

mattspieg

jsonToHtml

Public
Like
jsonToHtml
Home
Code
2
README.md
H
index.ts
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
Code
/
Search
index.ts
https://mattspieg--4ff07e5c602e11f0a1c70224a6c84d84.web.val.run
README.md

JSON to HTML Template Converter

A serverless function that converts structured JSON form data into a well-formatted HTML template with proper categorization and styling.

Features

  • Automatic Categorization: Groups form fields by section numbers (1., 2., 3., etc.)
  • Subsection Organization: Further organizes fields into logical subsections (2.1, 2.2, etc.)
  • Rich Formatting:
    • Boolean values displayed as colored Yes/No
    • Email addresses become clickable mailto links
    • URLs become clickable links
    • Dates are formatted for readability
    • Long text gets automatic line breaks
  • Professional Styling: Clean, responsive design with proper typography
  • Flexible Structure: Handles optional sections (only shows sections with data)

Usage

Send a POST request to the endpoint with JSON data:

curl -X POST https://your-val-town-url.web.val.run \ -H "Content-Type: application/json" \ -d '{"firstname": "John", "1. lastname": "Doe", "2.1. Assessment Type": "Full Audit"}'

Input Format

The function expects JSON with keys that follow this pattern:

  • firstname - Special case for first name
  • 1. or 1. prefix - General information
  • 2. or 2. prefix - Desktop assessment details
  • 3. or 3. prefix - Browser extension details
  • 4. or 4. prefix - Mobile assessment details
  • 5. or 5. prefix - Additional information
  • utm_*, referrer, etc. - Tracking information

Output Sections

  1. General Project & Contact Information
  2. Desktop Wallet Assessment (if applicable)
    • 2.1 Scope of Work (Desktop)
    • 2.2 Desktop Codebase Details
    • 2.3 Security Goals & Concerns (Desktop)
    • 2.4 Worst-Case Scenario Assessment (Desktop)
    • 2.5 Access & Logistics (Desktop)
    • 2.6 Timeline & Schedule (Desktop)
    • 2.7 Budget (Desktop)
  3. Browser Extension Wallet Assessment (if applicable)
    • Similar subsection structure
  4. Mobile Wallet Assessment (if applicable)
    • Similar subsection structure
  5. Additional Information (if applicable)
  6. Tracking Information (if present)

Response

Returns a complete HTML document with:

  • Responsive design optimized for 800px max width
  • Professional styling with color-coded sections
  • Proper semantic HTML structure
  • Inline CSS for portability

Error Handling

  • Returns 405 for non-POST requests
  • Returns 400 for invalid JSON
  • Gracefully handles missing or malformed fields
HTTP
  • index.ts
    mattspieg--4f…84.web.val.run
Code
README.md
H
index.ts
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareersBrandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.