Skip to main content

PSD to UI JSON converter with MCP tools

Project description

PSD UI Converter

A powerful PSD (Photoshop Document) to UI JSON converter powered by MCP (Model Context Protocol). Extracts structured metadata from PSD files and converts them into semantic, production-ready UI component definitions.

Overview

This tool parses PSD files and outputs a well-organized JSON structure containing:

  • Layer hierarchy — Nested layer tree with names, types, and visibility
  • Layout inference — Flexbox layout properties (direction, alignment, gap, padding)
  • CSS styles — Colors, gradients, shadows, borders, typography
  • Design tokens — Normalized colors, font sizes, and font families
  • Image assets — Exported PNG assets from smart objects and marked layers

Features

  • Smart layer parsing — Supports text, groups, smart objects, shapes, and pixel layers
  • Gradient extraction — Linear, radial, and conic gradients with accurate stop positions
  • Shadow effects — Drop shadows and inner shadows with blend modes
  • Layout inference — Automatically detects flexbox direction, alignment, and spacing
  • Mask support — Clipping masks and layer masks with export capability
  • Blend modes — Full support for PSD blend modes (multiply, screen, overlay, etc.)
  • Design token collection — Aggregates and normalizes design system values
  • MCP integration — Works as MCP tools for AI-assisted workflows

MCP Tools

This package provides two MCP tools for integration with AI coding assistants:

parse_psd_to_json

Parses a PSD file and outputs structured JSON data.

parse_psd_to_json(
    input_path: str,      # PSD file absolute path (required)
    output_json: str = None,  # JSON output path (optional)
    output_assets: str = "assets"  # Assets directory (default: "assets")
)

Returns:

  • json_path: Path to the generated JSON file
  • assets_dir: Path to exported assets directory
  • summary: Statistics including canvas size, total layers, colors count, font families
  • success: Boolean indicating success/failure

export_psd_images

Exports image resources from a PSD file to a specified directory.

export_psd_images(
    input_path: str,      # PSD file absolute path (required)
    output_assets: str = "assets"  # Assets directory (default: "assets")
)

Returns:

  • images: List of exported images with name, path, and layer_id
  • output_dir: Path to exported assets directory
  • success: Boolean indicating success/failure

CLI Usage

# Parse PSD and export assets
python -m src.psd_converter.psd_ui_converter -i /path/to/design.psd -oa assets -oj output.json

Arguments

Argument Description Default
-i, --input Absolute path to PSD file Required
-oa, --output-assets Directory for exported image assets assets
-oj, --output-json Output JSON file path {name}_structure.json

Example

python -m src.psd_converter.psd_ui_converter \
  -i /Volumes/Design/limitedTimeOffer.psd \
  -oa ./assets \
  -oj ./output/limitedTimeOffer_structure.json

Output Structure

{
  "meta": {
    "canvas": { "w": 1920, "h": 1080 },
    "version": "1.0"
  },
  "designTokens": {
    "colors": { "orange": "rgb(255, 131, 64)", "white": "rgb(255, 255, 255)" },
    "fontSizes": { "title": "32px", "body": "14px" },
    "fontFamilies": ["PingFang SC", "Microsoft YaHei"]
  },
  "layers": [
    {
      "id": 1,
      "name": "Background",
      "type": "group",
      "componentType": "background",
      "zIndex": 100,
      "rect": { "x": 0, "y": 0, "w": 1920, "h": 1080 },
      "layout": {
        "flexDirection": "column",
        "alignItems": "center",
        "justifyContent": "center",
        "gap": 20
      },
      "css": { "background": "linear-gradient(180deg, ...)" },
      "children": [...]
    }
  ]
}

Layer Type Markers

Use these naming conventions in your PSD to guide the parser:

Marker Type Description
@img, @image, @photo, @pic image Export as image asset
@text, @label, @txt text Text layer
@btn, @button button Button element
@icon icon Icon asset
@card card Card component
@bg, @background background Background layer

Smart Object Markers

Marker Behavior
@smart, @so Recursively parse nested layers

Running as MCP Server

To run this as an MCP server for AI integration:

# Using FastMCP
fastmcp run src.psd_converter.psd_converter_mcp:main

# Or directly
python -m src.psd_converter.psd_converter_mcp

Integration

The output JSON integrates with AI-powered frontend code generation. See skills/skills.md for Vue 3 component generation guidelines.

License

MIT

Project details


Download files

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

Source Distribution

psd_converter-0.1.0.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

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

psd_converter-0.1.0-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file psd_converter-0.1.0.tar.gz.

File metadata

  • Download URL: psd_converter-0.1.0.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for psd_converter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4b72f49d6919fc1e10e042856140b073a9347c02d0eb9430521d4efcda79ed7c
MD5 b17194c466037fb7a731d49a5ea688ca
BLAKE2b-256 ef3e37f17366984f171a0ad00af57d74c655ad3913077532b8a685dc76c3b88e

See more details on using hashes here.

File details

Details for the file psd_converter-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: psd_converter-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for psd_converter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 16fd3c9951a010c758632e9b30614588ac26dd32a7bdb551033b21d212de8535
MD5 cc412a33c33ef4ccdfe9875c94860916
BLAKE2b-256 a877c1b0e6baaffd8ec80cbfc448f0aaea486f046853bd6caf30c298a2ec2d15

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