A laptop, a phone and a hand writing in a notebook on a wooden desk, banner image on the Figma to Code page

ツール/ Buildスイート

Figma to Code

FigmaのフレームをクリーンなHTMLとCSSに変換します。フレームをSVGとしてエクスポートして貼り付けるだけです

ハンドオフの溝は実在します。デザインはFigmaにあり、エンジニアはマークアップを必要としています。Figmaでフレームを右クリックして Copy as SVG を選び(またはエクスポート)、下に貼り付けます。コンバーターは実際のシェイプ(実際の位置、色、テキスト)を読み取り、読めるHTMLとCSSをライブプレビューとダウンロードつきで返します。すべてブラウザー内で動き、何もアップロードされません。

スタンドアロンのワークスペースを開く

Screenshot of the Figma to Code tool

エクスポートしたSVGを貼り付け

実例

ツールそのものからの実際の出力。

これはFigma to Codeが示した入力例に対して返したもので、ツール自体からキャプチャーした実際の出力です。モックアップではありません。

あなたが入力

エクスポートされたSVG(貼り付け)

<svg width="320" height="180" viewBox="0 0 320 180" xmlns="http://www.w3.org/2000/svg"><rect x="0" y="0" width="320" height="180" rx="16" fill="#5a5a5a"/><text x="24" y="52" font-size="28" fill="#ffffff" font-family="Inter">Hire faster</text><rect x="24" y="76" width="120" height="36" rx="8" fill="#ffffff"/><text x="44" y="99" font-size="15" fill="#5a5a5a" font-family="Inter">Sign up</text></svg>

ツールが返す

Generated HTML

<div class="frame">

  <div class="rect"></div>
  <div class="text">Hire faster</div>
  <div class="rect-2"></div>
  <div class="text-2">Sign up</div>
  </div>

Generated CSS

.frame { position:relative; width:320px; height:180px; overflow:hidden; margin:24px auto; background:#fff; }
.rect { position:absolute;left:0px;top:0px;width:320px;height:180px;background:#5a5a5a;border-radius:16px; }
.text { position:absolute;top:24px;font-size:28px;font-family:Inter;white-space:pre;color:#ffffff;left:24px; }
.rect-2 { position:absolute;left:24px;top:76px;width:120px;height:36px;background:#ffffff;border-radius:8px; }
.text-2 { position:absolute;top:84px;font-size:15px;font-family:Inter;white-space:pre;color:#5a5a5a;left:44px; }
自分の入力で試す

できること

推測ではなく、シェイプから。

実際のデザインデータ

FigmaのSVGエクスポートには、正確なサイズ、位置、塗り、角丸、フォント情報つきのテキストが含まれます。コードは目測ではなくそのデータから導かれます。

設計からプライベート

SVGはご自身で貼り付けるので、プライベートなチームファイルも問題なく使えます。何も取得されず、ブラウザーから出るものもありません。Figmaへの接続を承認する必要もありません。

読みやすい出力

クラス名はレイヤー名から取られ、色はHex、テキストは内容とフォントサイズを保持します。そこから作り込める忠実な静的レンダリングです。

範囲を明確に

出力は静的なHTMLとCSSです。長方形、円、線、テキストは要素に変わり、複雑なパスは失われないようインラインベクターのまま残ります。オートレイアウトは固定配置に変わり、インタラクティブなコンポーネント、バリアント、プロトタイプは対象外です。

Copy as SVG が唯一の橋渡し

Figmaでフレームを右クリック、Copy as SVG、貼り付け。プラグインもトークンもアカウント接続も不要です。

4つのシェイプが要素になる

長方形、円、線、テキストノードが、対応するCSSを持つ配置済みのHTML要素に変わります。

推測ではなく実際の値

サイズ、位置、塗り、角丸はSVG自身の属性とスタイルから読み取られます。

サンドボックス内プレビュー

生成されたページは同じ画面内の隔離されたフレームに描画されるので、ダウンロード前に結果を確認できます。

クリーンなクラス名

レイヤー名は小文字化・ハイフン区切り化され、40文字に制限されます。CSSが自分で書いたように読めます。

出力は1ファイル

マークアップとスタイルがまとまった単一の .html ファイルをダウンロードします。そのまま開いたり調整したりできます。

使い方の流れ

SVGを入れて、マークアップを出す。

手順1

Figmaでフレームを右クリックし、Copy/Paste as から Copy as SVG を選びます(または右パネルの Export を使います)。

手順2

上にSVGマークアップを貼って変換すると、シェイプが検査用に読み込まれます。

手順3

ライブプレビューを確認し、HTMLとCSSをコピーするか、1つのファイルをダウンロードします。

よくある質問

Figmaのトークンやアカウント接続は必要ですか?

いいえ。SVGはFigmaからご自身でエクスポートして貼り付けるので、Figmaファイルに接続することはなく、プライベートなチームファイルも同じように使えます。

オートレイアウトは?

正確な固定配置として描画されます。見た目は忠実、構造はシンプルです。作り込む際にflexboxへ流し替えてください。

画像と複雑なベクターは?

画像は正確な範囲を示すラベル付きプレースホルダーになります。複雑なパスは正しい位置とサイズのインラインSVGとして保持されるので、レンダリングの忠実さが保たれます。

どのFigmaエクスポート?

フレーム上で Copy as SVG。そのマークアップには、コンバーターが読み取る位置と塗りの情報が含まれています。

画像は扱えますか?

画像の塗りとリンクされたアセットはスキップされ、シェイプとテキストは変換されます。何が変換されたかはプレビューで確認してください。

デザインはどこへ行きますか?

どこにも。変換はブラウザーのタブ内で行われ、SVGがアップロードされることはありません。

レスポンシブ対応?

出力はフレームに合わせて絶対配置されます。流動的なレイアウトへの調整はご自身のエディターで行ってください。

Buildスイートのその他のツール

Font Pairing LabWebhook TesterPricing Page BuilderLanding Page MakerStatus Page Starter
A laptop, headphones, a camera, a phone and a plant on a white desk, seen from above, banner image on the Figma to Code page

今すぐ試す。

Figma to Codeはブラウザー内で動きます。アカウントは不要です。

入力から出力へ

SVGを入れて、HTMLとCSSを出す

SVG copiedfrom FigmaA live preview生成されたHTML生成されたCSSA .htmldownloadFigma to CodeInOut
InSVG copied from FigmaFigma to CodeA live preview生成されたHTML生成されたCSSA .html downloadOut
貼り付けたFigmaフレームがページ内の配置されたシェイプに変わります。

パイプライン

4つのステップ

Right-click theframe in FigmaChoose Copy as SVGPaste it into theboxConvert, thendownload
Right-click the frame in FigmaChoose Copy as SVGPaste it into the boxConvert, then download
Figmaからファイルへ。

仕様シート

9つのタグが要素になる

rectdiv: size, fill, border,radiuscircle, ellipsediv with border-radius 50%linerotated divtextdiv with the words and fontimagelabeled placeholder boxpath, polyline, polygonkept as inline SVG
rectdiv: size, fill, border, radiuscircle, ellipsediv with border-radius 50%linerotated divtextdiv with the words and fontimagelabeled placeholder boxpath, polyline, polygonkept as inline SVG
各SVGタグが何に変わるか。

パイプライン

ツリーの走査

Enter svg, g, aand switchAdd up translate()offsetsSkip defs, masks,patterns andsymbolsStop after 24levels of nesting
Enter svg, g, a and switchAdd up translate() offsetsSkip defs, masks, patterns andsymbolsStop after 24 levels of nesting
コンテナーは内部に入り、オフセットは累積します。

ビフォー アフター

rectからCSSへ

SVG attributeCSSx and ywidth and heightfillstrokerxleft and topwidth and heightbackgroundborderborder-radius
SVG attribute to CSSx and yleft and topwidth and heightwidth and heightfillbackgroundstrokeborderrxborder-radius
長方形はボックスになります。

ビフォー アフター

circleからCSSへ

SVG attributeCSScx and cyrfillstrokeleft and top from the centerwidth and height of twice rbackgroundborder
SVG attribute to CSScx and cyleft and top from the centerrwidth and height of twice rfillbackgroundstrokeborder
円は丸いボックスになります。

ビフォー アフター

線は回転したdivになります

Line endpointsDiv0,0 to 100,00,0 to 100,10010,10 to 10,60100px long, rotate 0deg141.42px long, rotate 45deg50px long, rotate 90deg
Line endpoints to Div0,0 to 100,0100px long, rotate 0deg0,0 to 100,100141.42px long, rotate 45deg10,10 to 10,6050px long, rotate 90deg
長さは斜辺から、角度はatan2から求めます。

仕様シート

位置の計算方法

Root viewBoxoffset subtracted oncetranslate()added down the treeDecimalsrounded to two, in pxMissing sizeviewBox, else 800 x 600
Root viewBoxoffset subtracted oncetranslate()added down the treeDecimalsrounded to two, in pxMissing sizeviewBox, else 800 x 600
すべての要素が絶対座標に配置されます。

仕様シート

クラス名のルール

Sourceid or data-nameCaselowercased, runs becomedashesLeading digitx prependedLength cap40 charactersName repeats-2, -3 and so onNo namefalls back to the shape kind
Sourceid or data-nameCaselowercased, runs become dashesLeading digitx prependedLength cap40 charactersName repeats-2, -3 and so onNo namefalls back to the shape kind
レイヤー名が安全なクラス名に変わります。

ビフォー アフター

レイヤー名からクラスへ

LayerClassHero Card3D IconHero Card (second)hero-cardx3d-iconhero-card-second
Layer to ClassHero Cardhero-card3D Iconx3d-iconHero Card (second)hero-card-second
例。

仕様シート

グラデーション

On kept vectorsdefs survive with the svglayerurl(#id) fillskept on vectorsurl() fills on shapesdroppedExternal urlsnever kept
On kept vectorsdefs survive with the svg layerurl(#id) fillskept on vectorsurl() fills on shapesdroppedExternal urlsnever kept
再現できる場所では保持されます。

仕様シート

サニタイザーが除去するもの

on* handlersremovedhref, xlink:hrefremovedstyle and classremoved from vectorsidremoved from shapesNon-local url()set to none
on* handlersremovedhref, xlink:hrefremovedstyle and classremoved from vectorsidremoved from shapesNon-local url()set to none
貼り付けたマークアップは使用前にクリーンアップされます。

パイプライン

安全なプレビュー

The full documentis built in memoryShown inside aniframe srcdocHTML and CSS shownin text areasNothing is sentanywhere
The full document is built inmemoryShown inside an iframe srcdocHTML and CSS shown in text areasNothing is sent anywhere
結果はページから移動せずに描画されます。

仕様シート

5つのステータスメッセージ

Empty pastePaste SVG markup first.Over the size limitToo large (2 MB max).UnparseableCould not parse that as SVG.Root is not svgNot an SVG document.Nothing convertibleNo convertible shapes found.
Empty pastePaste SVG markup first.Over the size limitToo large (2 MB max).UnparseableCould not parse that as SVG.Root is not svgNot an SVG document.Nothing convertibleNo convertible shapes found.
ツールが伝える内容を、短くしたメッセージで示します。

仕様シート

明確な制限

Paste size2,000,000 charactersNesting depth24 levelsClass name length40 characters
Paste size2,000,000 charactersNesting depth24 levelsClass name length40 characters
コンバーター内の定数。

仕様シート

出力のレイアウト

Frameposition: relativeEvery elementposition: absoluteFrame overflowhiddenVectorsone svg layer on top
Frameposition: relativeEvery elementposition: absoluteFrame overflowhiddenVectorsone svg layer on top
1つのフレーム、絶対配置された子要素。

パイプライン

変換からダウンロードまで

Convert builds thedocumentThe previewrenders in theframeThe downloadbutton startsdisabledA successfulconvert unlocks itClick savesfigma-frame.html
Convert builds the documentThe preview renders in the frameThe download button startsdisabledA successful convert unlocks itClick saves figma-frame.html
ダウンロードボタンは結果が出るまで待ちます。

パイプライン

すべてローカルで動きます

Parsing uses thebrowser DOMParserNo network callsanywhereDownload is alocal blob file
Parsing uses the browser DOMParserNo network calls anywhereDownload is a local blob file
SVGがページの外に出ることはありません。