Skip to content

JSON to TypeScript emits invalid interfaces for non-identifier root names #353

Description

@baixiangcpp

Summary

JSON → TypeScript uses the root-name textbox verbatim when generating the root interface. Names containing a hyphen or beginning with a digit produce invalid TypeScript declarations.

Affected route: https://byteflow.tools/en/json-to-typescript

Reproduction

Use this valid JSON input:

   {"id":1}

Set the Root: field to user-profile.

Actual output:

   export interface user-profile { id: number; }

This is parsed as an invalid interface name because - is not allowed in a TypeScript identifier.

Set the Root: field to 123.

Actual output:

   export interface 123 { id: number; }

This is also invalid TypeScript because an identifier cannot start with a digit.

Expected

The tool should either sanitize the root name into a valid PascalCase identifier (for example UserProfile and Root123) or show validation feedback and require a valid identifier.

A normal root name such as ApiResponse generated valid nested interfaces and copied correctly during the same test.

Environment

  • Browser: Chrome via cloud browser
  • Tested: 2026-08-18

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions