Skip to main content

Write types once, use everywhere

Project description

SyncLangs

One centralized types file -> Multiple languages across all your codebases.

PyPI version Python versions License: MIT

SyncLangs is a developer tool that enables you to maintain a single source of truth for your type definitions. Define your structures once in a universal schema language (.syln) and automatically synchronize them as native, idiomatic types across Python, TypeScript, and multiple projects or packages simultaneously.

Why SyncLangs?

Modern full-stack applications often use different languages for frontend (TypeScript) and backend (Python). This creates type duplication, drift risk, and maintenance burden.

SyncLangs solves this by:

  • No more type drift - Define types once, generate native code for each language
  • Zero config start - Works immediately with sensible defaults
  • Fast watch mode - Regenerates in under 200ms on file save
  • Readable syntax - Human-readable .syln files, no verbose boilerplate

Quick Start

Installation

pip install synclangs
# or
pipx install synclangs

Initialize a Project

syln init

This creates:

  • syln.config.json - Configuration file
  • shared/example.syln - Example schema

Define Your Types

Create shared/user.syln:

## Represents a user in the system
type User {
  ## Unique identifier
  id: string

  ## User's email address
  email: string

  ## Display name (optional)
  name: string?

  ## Account active status
  isActive: bool

  ## User tags
  tags: list<string>

  ## Arbitrary metadata
  metadata: map<string, any>
}

Generate Code

syln generate

TypeScript Output (user.types.ts):

// Auto-generated by SyncLangs - DO NOT EDIT

export interface User {
  /** Unique identifier */
  id: string;
  /** User's email address */
  email: string;
  /** Display name (optional) */
  name?: string;
  /** Account active status */
  isActive: boolean;
  /** User tags */
  tags: string[];
  /** Arbitrary metadata */
  metadata: Record<string, any>;
}

Python Output (user_types.py):

# Auto-generated by SyncLangs - DO NOT EDIT

from dataclasses import dataclass
from typing import Any, Optional

@dataclass
class User:
    """Represents a user in the system"""
    id: str
    """Unique identifier"""
    email: str
    """User's email address"""
    is_active: bool
    """Account active status"""
    tags: list[str]
    """User tags"""
    metadata: dict[str, Any]
    """Arbitrary metadata"""
    name: Optional[str] = None
    """Display name (optional)"""

Watch Mode

syln watch

Changes to .syln files automatically regenerate output in under 200ms.

CLI Reference

Command Description
syln init Initialize a new project with config and example
syln generate Generate code from .syln files
syln check Validate schemas without generating
syln watch Watch mode with auto-regeneration
syln version Show version

Common Flags

Flag Short Description
--config -c Config file path (default: ./syln.config.json)
--input -i Input directory (default: ./shared)
--out-ts TypeScript output directory
--out-py Python output directory
--verbose -v Verbose logging
--dry-run Show what would be generated

Syntax Reference

Primitives

SyncLangs Python TypeScript
string str string
int int number
float float number
bool bool boolean
any Any any

Generics

SyncLangs Python TypeScript
list<T> list[T] T[]
map<K, V> dict[K, V] Record<K, V>

Nullable Types

type Example {
  required: string      # Required field
  optional: string?     # Optional field (nullable)
}

Imports

import { User, Address } from "./user.syln"

type Order {
  user: User
  shippingAddress: Address
}

Comments

# Regular comment (ignored in output)

## Doc comment (generates docstrings/JSDoc)
type User {
  ## The user's unique identifier
  id: string
}

Configuration

Create syln.config.json in your project root:

{
  "$schema": "https://synclangs.com/schema/v1.json",
  "version": "1.0",
  "input": "./shared",
  "outputs": {
    "typescript": {
      "enabled": true,
      "outDir": "./generated/ts",
      "fileExtension": ".types.ts"
    },
    "python": {
      "enabled": true,
      "outDir": "./generated/py",
      "fileExtension": "_types.py",
      "useDataclasses": true
    }
  },
  "options": {
    "watchDebounceMs": 100,
    "caseConversion": {
      "fields": {
        "python": "snake_case",
        "typescript": "camelCase"
      }
    },
    "generateIndex": true
  }
}

Error Messages

SyncLangs provides helpful error messages with file locations and suggestions:

Error: SY002 - Invalid type reference
  --> shared/user.syln:15:12
   |
15 |   role: Roles
   |         ^^^^^ Type 'Roles' not found. Did you mean 'Role'?
   |
Help: Import 'Roles' or define it in this file.

Documentation

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting a PR.

License

MIT - see LICENSE


Made with care by SyncLangs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

synclangs-0.2.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (14.4 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

synclangs-0.2.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (15.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

synclangs-0.2.1-cp313-cp313-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

synclangs-0.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (14.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

synclangs-0.2.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (15.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

synclangs-0.2.1-cp312-cp312-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

synclangs-0.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (14.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

synclangs-0.2.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (15.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

synclangs-0.2.1-cp311-cp311-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

synclangs-0.2.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

synclangs-0.2.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (14.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

synclangs-0.2.1-cp310-cp310-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file synclangs-0.2.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 dee72fe2b390cc533073d87029650adb307c74e1be5122f491a39fbdb6250d72
MD5 a9b871dc232cf6db3ed7d08dfa5c2b19
BLAKE2b-256 2f17d58a31c4d5cab7c379fbc760c8b5633c3afbb0f1aa657a2553a26752fea9

See more details on using hashes here.

File details

Details for the file synclangs-0.2.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 089cf4729766923afde9db46f51390a6bc2da2677895d7476401e50b92c2c3b4
MD5 bf867d565b30ba5e12f615781b449af3
BLAKE2b-256 57aa379643ea58cd6bb405f117c8550090a6336807224b4f5edaf62546d117e4

See more details on using hashes here.

File details

Details for the file synclangs-0.2.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 64626947350922c164edf38050a6ee678682a5e6b65be73096925c362e0852be
MD5 f832ed56dea1ceddef2409489e4f8e74
BLAKE2b-256 42e892775bfafec089b7ef162b30a96e19876160f7301f2b8439e77e550cc46f

See more details on using hashes here.

File details

Details for the file synclangs-0.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 959164867207f3060956d8ee429c0bf6b914c53ab5e723a0d1b3b3f2f04d80f0
MD5 853daae33fc5e41b0f95879b67f85157
BLAKE2b-256 8d9898bfcde8d6a38030708f884d8b8a1f16ec5dcac0b5e540ee09d2189f2d6a

See more details on using hashes here.

File details

Details for the file synclangs-0.2.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 760679a009a31d5acbcc80ca5f1d27ca565453fe2d610031e2853ebb4b9e7a67
MD5 f98593d1f8033e5b064400bd1a07d16a
BLAKE2b-256 9d819c4c0a9103cb048a504db3bf3638f9084e3e9828590fcf0b9c2ba0ac09a4

See more details on using hashes here.

File details

Details for the file synclangs-0.2.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8d590fb9ad9412506b8a71635efd517d6b3d5fec84fede8849f5daec84cc637e
MD5 19fe90311ef7bfe47d7e178d480a96c3
BLAKE2b-256 48f540594200074ae3ef1929c087a4403be1ab6f7c4dce282d57bc608ec6f1f0

See more details on using hashes here.

File details

Details for the file synclangs-0.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 d8e9964285c2a68143884c23c1e7c6b84f4c66143a2fec4dc28a821e5e566413
MD5 590168c4293f9e5de9235fb307d3056f
BLAKE2b-256 c8b68cd2fa583491b226b03b8fbb6325e0a6a82252863d1da6c915d7fd4cae5c

See more details on using hashes here.

File details

Details for the file synclangs-0.2.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a252fa955afe7c2c8d8a1a27825762032f8a4dd1c76f56009d5a4722c8cc6765
MD5 39792d09588d69ab2cbe351bd829323d
BLAKE2b-256 4160a49f14ffe77f1779539d14444f8f89c97f7d38ea62f8363081d020970209

See more details on using hashes here.

File details

Details for the file synclangs-0.2.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ee1b73ef0df29a1b3df31424b93c6e00de835d4e518ae170e040a8d8d9c3d2c4
MD5 481263a01ebfab7362192ec5ea89075d
BLAKE2b-256 4b052332d5f70c7d3a02e1e4ca273831c4352372632eefe564e37ec563210d4a

See more details on using hashes here.

File details

Details for the file synclangs-0.2.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 0bdf7dad70b4970f97b3ac7113c6eaa194e73b16823e02f13357bf2c437e7680
MD5 d58f59e02cdb89052ba37769e9777e7c
BLAKE2b-256 a9f039d1ae7a7ab5904441b06dbf983a7c19e73c445ea45621c6cd1629744247

See more details on using hashes here.

File details

Details for the file synclangs-0.2.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.1-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a40a8741af4290d5a83183864a2bf7f94841ba1f064a1492302d54e7c043a515
MD5 2fc72cca61822e65dfbdf17b6c67a5ea
BLAKE2b-256 7cfe79b25285fca672a40267428b636413a14c91978b480773715b300fae981b

See more details on using hashes here.

File details

Details for the file synclangs-0.2.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for synclangs-0.2.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a9b768b12385538be83c800845c92134d767d9958e80df98bf3c7f679b8fb89c
MD5 a7bcd26b3deeb43fe3b60ad9aedbc397
BLAKE2b-256 66dc31c36a760eeb0a0ac51a6b6c9029eb8ae5aac7f51480b17fde675d487e3d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page