npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ehzero/psd2json

v1.1.1

Published

A TypeScript library to convert PSD files to JSON format with React CSSProperties styling

Readme

psd2json

TypeScript library that converts Adobe Photoshop PSD files to JSON with React CSSProperties.

Installation

npm install @ehzero/psd2json

Quick Start

import { psd2json } from '@ehzero/psd2json';

const result = await psd2json(psdBuffer);

console.log('Text layers:', result.texts);
console.log('Image layers:', result.images);

API

psd2json(buffer, options?)

interface ConversionOptions {
  logging?: boolean;        // Enable logs (default: false)
  includeHidden?: boolean;  // Include hidden layers (default: false)
}

interface ConversionResult {
  texts: TextLayer[];       // Text layers with CSS properties
  images: ImageLayer[];     // Image layers with CSS properties
}

Layer Properties

interface TextLayer extends React.CSSProperties {
  value: string | undefined; // Text content
  // CSS properties: left, top, width, height, fontSize, color, etc.
}

interface ImageLayer extends React.CSSProperties {
  value: string | undefined; // Base64 image data
  // CSS properties: left, top, width, height, opacity, etc.
}

Examples

Basic Usage

const result = await psd2json(psdBuffer, {
  logging: true,
  includeHidden: false
});

result.texts.forEach(textLayer => {
  console.log('Text:', textLayer.value);
  console.log('Position:', textLayer.left, textLayer.top);
  console.log('Font:', textLayer.fontFamily, textLayer.fontSize);
});

React Integration

function PsdRenderer({ psdData }) {
  return (
    <div style={{ position: 'relative' }}>
      {psdData.texts.map((layer, i) => (
        <div key={i} style={layer}>
          {layer.value}
        </div>
      ))}

      {psdData.images.map((layer, i) => (
        <div
          key={i}
          style={{
            ...layer,
            backgroundImage: layer.value ? `url(${layer.value})` : undefined
          }}
        />
      ))}
    </div>
  );
}

Node.js Setup

import { initializePsd2JsonForNode } from '@ehzero/psd2json';
import * as canvas from 'canvas';

// Required for image processing in Node.js
initializePsd2JsonForNode(canvas);

Output Format

All dimensions are returned as pixel strings:

{
  position: 'absolute',
  left: '100px',
  top: '50px',
  width: '400px',
  height: '70px',
  fontSize: '36px',
  opacity: 0.9,           // number (0-1)
  letterSpacing: '0.05em', // string with em
  lineHeight: 1.2          // unitless number
}

Supported Features

  • Text layers: fonts, colors, positioning, effects
  • Image layers: positioning, opacity, blend modes
  • Layer effects: shadows, glows, strokes
  • TypeScript definitions
  • React CSSProperties compatibility

Error Handling

import { psd2json, PsdConversionError } from '@ehzero/psd2json';

try {
  const result = await psd2json(buffer);
} catch (error) {
  if (error instanceof PsdConversionError) {
    console.error('PSD Error:', error.message);
  }
}

License

MIT