Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
1626 lines (1570 loc) · 66.8 KB
/
Copy pathindex.html
File metadata and controls
1626 lines (1570 loc) · 66.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- ── SEO: primary ────────────────────────────── -->
<title>
SQL 转 ER 图在线工具 · Chen 模型生成器 | SQL / DBML to ER Diagram — sql2er
</title>
<meta
name="description"
content="免费在线 SQL 转 ER 图工具:把 CREATE TABLE 建表语句或 DBML 一键生成 Chen 模型实体-关系图。纯前端运行,数据不出浏览器,无需登录、不埋点;支持 PostgreSQL / MySQL / SQLite 语法,节点可拖动、双击改名,可导出 SVG / PNG。Free online tool to convert SQL & DBML into Chen-model ER diagrams, 100% client-side and open source."
/>
<meta
name="keywords"
content="SQL 转 ER 图, SQL 转 ER 图在线工具, 免费 SQL 转 ER 图,ER 图生成器, ER图在线生成, 实体关系图, Chen 模型, 陈氏模型, 数据库建模工具, CREATE TABLE 可视化, DBML 转 ER 图, 数据库 ER 图, PostgreSQL ER 图, MySQL ER 图, SQLite ER 图, 开源 ER 工具, sql2er, SQL to ER diagram, ER diagram generator, Chen model ERD, DBML to ER, database diagram, entity relationship diagram, free ER tool, open source ERD, PostgreSQL ER diagram, MySQL ER diagram"
/>
<meta name="author" content="ystemsrx" />
<meta
name="robots"
content="index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1"
/>
<meta
name="googlebot"
content="index, follow, max-image-preview:large, max-snippet:-1"
/>
<meta name="bingbot" content="index, follow" />
<meta
name="theme-color"
content="#ECE9E0"
media="(prefers-color-scheme: light)"
/>
<meta
name="theme-color"
content="#1A1916"
media="(prefers-color-scheme: dark)"
/>
<meta name="format-detection" content="telephone=no" />
<meta name="referrer" content="strict-origin-when-cross-origin" />
<meta name="application-name" content="sql2er" />
<meta name="apple-mobile-web-app-title" content="sql2er" />
<link rel="canonical" href="https://ystemsrx.github.io/sql_to_ER/" />
<link
rel="alternate"
hreflang="zh-CN"
href="https://ystemsrx.github.io/sql_to_ER/"
/>
<link
rel="alternate"
hreflang="en"
href="https://ystemsrx.github.io/sql_to_ER/"
/>
<link
rel="alternate"
hreflang="x-default"
href="https://ystemsrx.github.io/sql_to_ER/"
/>
<!-- ── SEO: Open Graph ─────────────────────────── -->
<meta property="og:type" content="website" />
<meta property="og:site_name" content="sql2er · SQL 转 ER 图" />
<meta
property="og:title"
content="SQL 转 ER 图在线工具 · Chen 模型生成器 | SQL / DBML to ER Diagram"
/>
<meta
property="og:description"
content="把 SQL CREATE TABLE 或 DBML 一键转成 Chen 模型 ER 图,纯前端、开源、免登录。Turn SQL / DBML into Chen-model ER diagrams — free, open source, 100% client-side."
/>
<meta property="og:url" content="https://ystemsrx.github.io/sql_to_ER/" />
<meta
property="og:image"
content="https://ystemsrx.github.io/sql_to_ER/assets/eg1.png"
/>
<meta
property="og:image:alt"
content="sql2er 生成的 Chen 模型 ER 图示例 / Example Chen-model ER diagram produced by sql2er"
/>
<meta property="og:locale" content="zh_CN" />
<meta property="og:locale:alternate" content="en_US" />
<!-- ── SEO: Twitter Card ────────────────────────── -->
<meta name="twitter:card" content="summary_large_image" />
<meta
name="twitter:title"
content="SQL 转 ER 图在线工具 · Chen 模型生成器 | sql2er"
/>
<meta
name="twitter:description"
content="把 SQL / DBML 一键生成 Chen 模型 ER 图,纯前端、开源、免登录。Free online SQL & DBML → Chen-model ER diagram generator."
/>
<meta
name="twitter:image"
content="https://ystemsrx.github.io/sql_to_ER/assets/eg1.png"
/>
<meta
name="twitter:image:alt"
content="sql2er 生成的 Chen 模型 ER 图示例"
/>
<meta name="twitter:creator" content="@ystemsrx" />
<!-- ── SEO: Schema.org JSON-LD ──────────────────── -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "SoftwareApplication",
"name": "sql2er · SQL 转 ER 图",
"alternateName": [
"sql2er",
"SQL to ER diagram",
"SQL / DBML → ER Diagram Generator",
"SQL 转 ER 图在线工具",
"Chen 模型 ER 图生成器",
"数据库 ER 图生成器"
],
"description": "免费开源、纯前端的 SQL / DBML 转 Chen 模型 ER 图在线工具。Free, open-source, pure front-end tool that converts SQL CREATE TABLE statements and DBML into Chen-model ER diagrams.",
"url": "https://ystemsrx.github.io/sql_to_ER/",
"image": "https://ystemsrx.github.io/sql_to_ER/assets/eg1.png",
"applicationCategory": "DeveloperApplication",
"applicationSubCategory": "Database tool",
"operatingSystem": "Any (browser)",
"browserRequirements": "Requires JavaScript. Requires HTML5.",
"offers": { "@type": "Offer", "price": "0", "priceCurrency": "USD" },
"license": "https://www.gnu.org/licenses/agpl-3.0.html",
"author": {
"@type": "Person",
"name": "ystemsrx",
"url": "https://github.com/ystemsrx"
},
"codeRepository": "https://github.com/ystemsrx/sql_to_ER",
"inLanguage": ["zh-CN", "en"],
"keywords": "SQL 转 ER 图, ER 图生成器, Chen 模型, DBML, 数据库建模, CREATE TABLE 可视化, SQL to ER diagram, DBML to ER, entity relationship diagram, open source ERD",
"featureList": [
"解析 SQL CREATE TABLE 建表语句 / Parse SQL CREATE TABLE statements",
"解析 DBML(Database Markup Language)/ Parse DBML",
"生成 Chen 模型 ER 图(实体 / 关系 / 属性)/ Generate Chen-model ER diagrams",
"力导向自动布局(force2)/ Force-directed auto layout",
"节点拖拽编辑 / Drag-and-drop node editing",
"双击重命名 / Double-click rename",
"智能调整与快速布局 / Smart adjustment and quick layout",
"导出 SVG / 图片 / Export as SVG / image",
"100% 浏览器本地运行,不上传数据 / 100% client-side, no upload"
]
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebSite",
"name": "sql2er · SQL 转 ER 图",
"url": "https://ystemsrx.github.io/sql_to_ER/",
"inLanguage": ["zh-CN", "en"],
"publisher": {
"@type": "Person",
"name": "ystemsrx",
"url": "https://github.com/ystemsrx"
}
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "sql2er 是什么?/ What is sql2er?",
"acceptedAnswer": {
"@type": "Answer",
"text": "sql2er 是一个免费开源、纯前端的在线工具,可以把 SQL CREATE TABLE 建表语句或 DBML 一键转换成 Chen 模型的实体-关系(ER)图。sql2er is a free, open-source, pure front-end tool that turns SQL or DBML into Chen-model ER diagrams."
}
},
{
"@type": "Question",
"name": "数据会被上传到服务器吗?/ Is my SQL uploaded anywhere?",
"acceptedAnswer": {
"@type": "Answer",
"text": "不会。所有解析和渲染都在浏览器本地完成,SQL 内容不会离开你的设备。No. All parsing and rendering happen in your browser — your SQL never leaves your device."
}
},
{
"@type": "Question",
"name": "支持哪些数据库方言?/ Which SQL dialects are supported?",
"acceptedAnswer": {
"@type": "Answer",
"text": "支持常见的 PostgreSQL、MySQL、SQLite 等 CREATE TABLE 语法,也支持 DBML。Common PostgreSQL / MySQL / SQLite CREATE TABLE syntax is supported, as well as DBML."
}
}
]
}
</script>
<!-- ── GEO: AI / LLM crawler policy ─────────────── -->
<!--
Generative Engine Optimization (GEO):显式允许主流 AI 检索 / 训练爬虫抓取,
让 ChatGPT / Claude / Perplexity / Gemini / You.com / Arc Search 等
生成式引擎可以正确引用本页内容。
-->
<meta name="GPTBot" content="index, follow" />
<meta name="ChatGPT-User" content="index, follow" />
<meta name="OAI-SearchBot" content="index, follow" />
<meta name="ClaudeBot" content="index, follow" />
<meta name="Claude-Web" content="index, follow" />
<meta name="anthropic-ai" content="index, follow" />
<meta name="PerplexityBot" content="index, follow" />
<meta name="Perplexity-User" content="index, follow" />
<meta name="Google-Extended" content="index, follow" />
<meta name="GoogleOther" content="index, follow" />
<meta name="Applebot" content="index, follow" />
<meta name="Applebot-Extended" content="index, follow" />
<meta name="Amazonbot" content="index, follow" />
<meta name="CCBot" content="index, follow" />
<meta name="Bytespider" content="index, follow" />
<meta name="DuckAssistBot" content="index, follow" />
<meta name="YouBot" content="index, follow" />
<meta name="cohere-ai" content="index, follow" />
<meta name="Diffbot" content="index, follow" />
<meta name="Meta-ExternalAgent" content="index, follow" />
<meta name="MistralAI-User" content="index, follow" />
<!-- ── GEO: AI 引用 / 抽取友好型摘要 ────────────── -->
<!--
下列 meta 提供给生成式引擎一份「直接可引用」的事实陈述,
包含产品名、能力、隐私属性、协议、维护者、规范链接。
-->
<meta
name="abstract"
content="sql2er 是一个免费、开源(AGPL-3.0)、纯前端的在线工具,可将 SQL CREATE TABLE 语句或 DBML 一键转换为 Chen 模型的实体-关系(ER)图。所有解析与渲染均在浏览器本地完成,SQL 不上传任何服务器,支持 PostgreSQL / MySQL / SQLite 语法以及 DBML,可导出 SVG / PNG。"
/>
<meta
name="summary"
content="sql2er = 在线 SQL/DBML → Chen 模型 ER 图生成器;100% 客户端运行;开源 AGPL-3.0;作者 ystemsrx;仓库 https://github.com/ystemsrx/sql_to_ER。"
/>
<meta name="topic" content="数据库建模, ER 图, Chen 模型, SQL 可视化, DBML" />
<meta name="category" content="Developer Tools / Database Modeling" />
<meta name="audience" content="软件工程师, 数据库设计师, 学生, 教师, 数据分析师" />
<meta name="rating" content="general" />
<meta name="distribution" content="global" />
<meta name="coverage" content="worldwide" />
<meta name="language" content="zh-CN, en" />
<meta
name="ai-content-declaration"
content="human-authored; open-source project; safe to cite; canonical URL https://ystemsrx.github.io/sql_to_ER/"
/>
<meta
name="generative-ai-policy"
content="allow-indexing; allow-citation; require-attribution-to=ystemsrx; canonical=https://ystemsrx.github.io/sql_to_ER/"
/>
<meta
name="usage-terms"
content="Source code is licensed under AGPL-3.0. The hosted web app is free to use without registration; no data is collected."
/>
<!-- ── GEO: Schema.org HowTo(步骤化指南,便于 AI 引用「怎么用」) ── -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "HowTo",
"name": "如何用 sql2er 把 SQL 转成 Chen 模型 ER 图 / How to convert SQL to a Chen-model ER diagram with sql2er",
"description": "使用 sql2er 在浏览器中把 CREATE TABLE 语句或 DBML 转换为 Chen 模型实体-关系图的完整步骤。Step-by-step guide to turn SQL CREATE TABLE statements or DBML into a Chen-model ER diagram entirely in the browser.",
"inLanguage": ["zh-CN", "en"],
"totalTime": "PT1M",
"tool": [
{ "@type": "HowToTool", "name": "现代浏览器 / Modern web browser" }
],
"supply": [
{
"@type": "HowToSupply",
"name": "SQL CREATE TABLE 建表语句或 DBML 文本 / SQL CREATE TABLE statements or DBML text"
}
],
"step": [
{
"@type": "HowToStep",
"position": 1,
"name": "打开 sql2er / Open sql2er",
"text": "在浏览器中访问 https://ystemsrx.github.io/sql_to_ER/ 。无需注册或登录。Open https://ystemsrx.github.io/sql_to_ER/ in any modern browser. No sign-up required.",
"url": "https://ystemsrx.github.io/sql_to_ER/"
},
{
"@type": "HowToStep",
"position": 2,
"name": "粘贴 SQL 或 DBML / Paste SQL or DBML",
"text": "把 CREATE TABLE 建表语句或 DBML 粘贴到左侧编辑器。支持 PostgreSQL / MySQL / SQLite 常见方言。Paste your CREATE TABLE statements or DBML into the left-hand editor. PostgreSQL / MySQL / SQLite syntax and DBML are supported."
},
{
"@type": "HowToStep",
"position": 3,
"name": "生成 ER 图 / Generate the ER diagram",
"text": "工具会在本地解析并以力导向布局自动渲染 Chen 模型 ER 图,节点可拖动、双击重命名。The tool parses your input locally and renders a Chen-model ER diagram with force-directed layout; nodes are draggable and can be renamed by double-clicking."
},
{
"@type": "HowToStep",
"position": 4,
"name": "导出 SVG / PNG / Export as SVG or PNG",
"text": "通过工具栏导出按钮把图保存为 SVG 或 PNG。Use the export button in the toolbar to save the diagram as SVG or PNG."
}
]
}
</script>
<!-- ── GEO: BreadcrumbList ─────────────────────── -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://ystemsrx.github.io/"
},
{
"@type": "ListItem",
"position": 2,
"name": "sql2er · SQL 转 ER 图",
"item": "https://ystemsrx.github.io/sql_to_ER/"
}
]
}
</script>
<!-- ── GEO: TechArticle(让 LLM 把本页当作可引用的技术参考) ── -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "TechArticle",
"headline": "把 SQL / DBML 转成 Chen 模型 ER 图:sql2er 使用与原理 / Convert SQL & DBML to Chen-model ER Diagrams with sql2er",
"description": "sql2er 是一个免费、开源、纯前端的在线工具,把 SQL CREATE TABLE 语句或 DBML 转换为 Chen 模型的实体-关系图,支持力导向布局、节点编辑与 SVG / PNG 导出。",
"url": "https://ystemsrx.github.io/sql_to_ER/",
"image": "https://ystemsrx.github.io/sql_to_ER/assets/eg1.png",
"inLanguage": ["zh-CN", "en"],
"isAccessibleForFree": true,
"keywords": "SQL 转 ER 图, Chen 模型, DBML, 数据库建模, ER diagram, entity relationship diagram, ERD, sql2er",
"about": [
{ "@type": "Thing", "name": "实体-关系模型 / Entity–relationship model" },
{ "@type": "Thing", "name": "Chen 模型 / Chen notation" },
{ "@type": "Thing", "name": "DBML / Database Markup Language" },
{ "@type": "Thing", "name": "SQL CREATE TABLE" }
],
"audience": {
"@type": "Audience",
"audienceType": "software engineers, database designers, students, data analysts"
},
"author": {
"@type": "Person",
"name": "ystemsrx",
"url": "https://github.com/ystemsrx",
"sameAs": ["https://github.com/ystemsrx"]
},
"publisher": {
"@type": "Person",
"name": "ystemsrx",
"url": "https://github.com/ystemsrx"
},
"license": "https://www.gnu.org/licenses/agpl-3.0.html",
"citation": [
{
"@type": "CreativeWork",
"name": "Chen, Peter Pin-Shan. The Entity-Relationship Model—Toward a Unified View of Data. ACM TODS, 1976.",
"url": "https://doi.org/10.1145/320434.320440"
},
{
"@type": "SoftwareSourceCode",
"name": "DBML — Database Markup Language",
"url": "https://dbml.dbdiagram.io/"
}
],
"mainEntityOfPage": "https://ystemsrx.github.io/sql_to_ER/"
}
</script>
<!-- ── GEO: Organization / Person sameAs(知识图谱锚点) ── -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Person",
"name": "ystemsrx",
"url": "https://github.com/ystemsrx",
"sameAs": [
"https://github.com/ystemsrx",
"https://github.com/ystemsrx/sql_to_ER"
],
"knowsAbout": [
"SQL",
"DBML",
"Entity-Relationship Modeling",
"Chen Notation",
"Data Visualization",
"Front-end Engineering"
]
}
</script>
<!-- ── Favicon (inline SVG, network/diagram icon) ── -->
<link
rel="icon"
type="image/svg+xml"
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23D97757' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='16' y='16' width='6' height='6' rx='1'/%3E%3Crect x='2' y='16' width='6' height='6' rx='1'/%3E%3Crect x='9' y='2' width='6' height='6' rx='1'/%3E%3Cpath d='M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3'/%3E%3Cpath d='M12 12V8'/%3E%3C/svg%3E"
/>
<!-- 同步主题脚本:必须在任何 CSS 之前执行,避免暗色用户白屏闪烁。
读取 localStorage["sql2er-theme"],无记录则跟随系统偏好;
未设置 data-theme 时 CSS 兜底跟随系统(noscript 亦然)。 -->
<script>
(function () {
try {
var t = localStorage.getItem("sql2er-theme");
if (t !== "light" && t !== "dark") {
t =
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light";
}
document.documentElement.setAttribute("data-theme", t);
} catch (e) {
/* localStorage 不可用时按系统偏好走 CSS 兜底 */
}
})();
</script>
<!-- 先字体,后 base -->
<link rel="stylesheet" href="./assets/fonts/fonts.css" />
<link rel="stylesheet" href="./assets/base.css" />
<link rel="stylesheet" href="./css/landing.css" />
<noscript>
<style>
.scroll-reveal {
opacity: 1;
transform: none;
}
</style>
</noscript>
</head>
<body>
<!-- NAV -->
<nav class="nav" id="nav" aria-label="主导航" data-i18n-aria="aria_nav">
<div class="nav-row">
<a href="#" class="brand" aria-label="SQL to ER diagram">
<span class="brand-mark" aria-hidden="true">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2.2"
stroke-linecap="round"
stroke-linejoin="round"
>
<rect x="16" y="16" width="6" height="6" rx="1" />
<rect x="2" y="16" width="6" height="6" rx="1" />
<rect x="9" y="2" width="6" height="6" rx="1" />
<path d="M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3" />
<path d="M12 12V8" />
</svg>
</span>
<span class="brand-name">SQL to ER diagram</span>
</a>
<div class="nav-links">
<a href="#features" data-i18n="nav_features">特性</a>
<a href="#demo" data-i18n="nav_demo">示例</a>
<a href="#how" data-i18n="nav_how">用法</a>
<a href="#faq" data-i18n="nav_faq">FAQ</a>
</div>
<div class="nav-actions">
<button
class="icon-btn"
id="langBtn"
aria-label="切换语言"
data-i18n-aria="aria_lang"
>
<span
id="langLabel"
style="
font-family: var(--font-heading);
font-size: 0.76rem;
font-weight: 600;
"
>EN</span
>
</button>
<button
class="icon-btn"
id="themeBtn"
aria-label="切换主题"
data-i18n-aria="aria_theme"
>
<svg
id="themeIcon"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" />
</svg>
</button>
<a
class="icon-btn"
href="https://github.com/ystemsrx/sql_to_ER"
target="_blank"
rel="noopener"
aria-label="GitHub"
>
<svg viewBox="0 0 24 24" fill="currentColor">
<path
d="M12 0C5.37 0 0 5.37 0 12c0 5.3 3.44 9.8 8.2 11.39.6.11.82-.26.82-.58 0-.29-.01-1.04-.02-2.05-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.09-.74.08-.73.08-.73 1.2.09 1.84 1.24 1.84 1.24 1.07 1.83 2.81 1.3 3.5 1 .11-.78.42-1.3.76-1.6-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.12-.3-.54-1.52.12-3.17 0 0 1.01-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.29-1.55 3.3-1.23 3.3-1.23.66 1.65.24 2.87.12 3.17.77.84 1.23 1.91 1.23 3.22 0 4.61-2.8 5.62-5.48 5.92.43.37.82 1.1.82 2.22 0 1.61-.01 2.9-.01 3.3 0 .32.22.7.83.58A12 12 0 0 0 24 12c0-6.63-5.37-12-12-12z"
/>
</svg>
</a>
</div>
</div>
</nav>
<!-- HERO -->
<header class="hero">
<div class="hero-grid">
<div>
<span class="eyebrow"
><span data-i18n="badge">Open source · Pure front-end</span></span
>
<h1 class="display hero-title">
<span data-i18n="hero1">把 SQL 建表语句,</span>
<span class="line-2" data-i18n-html="hero2"
>一键<em>翻译</em>成 ER 图</span
>
</h1>
<p class="hero-lead" data-i18n="lead">
基于 Chen 模型的在线 SQL / DBML
转换器。所有解析都在你的浏览器里发生,不上传、不登录、不计费。
</p>
<div class="hero-cta">
<a class="btn btn-primary" href="sql2er.html">
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<polyline points="5 12 19 12" />
<polyline points="12 5 19 12 12 19" />
</svg>
<span data-i18n="cta1">打开生成器</span>
</a>
<a
class="btn btn-ghost"
href="https://github.com/ystemsrx/sql_to_ER"
target="_blank"
rel="noopener"
>
<svg viewBox="0 0 24 24" fill="currentColor">
<path
d="M12 0C5.37 0 0 5.37 0 12c0 5.3 3.44 9.8 8.2 11.39.6.11.82-.26.82-.58 0-.29-.01-1.04-.02-2.05-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.09-.74.08-.73.08-.73 1.2.09 1.84 1.24 1.84 1.24 1.07 1.83 2.81 1.3 3.5 1 .11-.78.42-1.3.76-1.6-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.12-.3-.54-1.52.12-3.17 0 0 1.01-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.29-1.55 3.3-1.23 3.3-1.23.66 1.65.24 2.87.12 3.17.77.84 1.23 1.91 1.23 3.22 0 4.61-2.8 5.62-5.48 5.92.43.37.82 1.1.82 2.22 0 1.61-.01 2.9-.01 3.3 0 .32.22.7.83.58A12 12 0 0 0 24 12c0-6.63-5.37-12-12-12z"
/>
</svg>
<span data-i18n="cta2">Star on GitHub</span>
</a>
</div>
</div>
<!-- 真实 ER 图(G6 force2 默认布局)-->
<div class="er-stage" id="erStage">
<span class="er-chip" data-i18n="live">试试拖动</span>
<button
class="er-reset"
id="erReset"
aria-label="重置布局"
data-i18n-aria="aria_reset"
>
<svg viewBox="0 0 512 512" aria-hidden="true" focusable="false">
<path d="M105.1 202.6c7.7-21.8 20.2-42.3 37.8-59.8c62.5-62.5 163.8-62.5 226.3 0L386.3 160 352 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l111.5 0c0 0 0 0 0 0l.4 0c17.7 0 32-14.3 32-32l0-112c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 35.2L414.4 97.6c-87.5-87.5-229.3-87.5-316.8 0C73.2 122 55.6 150.7 44.8 181.4c-5.9 16.7 2.9 34.9 19.5 40.8s34.9-2.9 40.8-19.5zM39 289.3c-5 1.5-9.8 4.2-13.7 8.2c-4 4-6.7 8.8-8.1 14c-.3 1.2-.6 2.5-.8 3.8c-.3 1.7-.4 3.4-.4 5.1L16 432c0 17.7 14.3 32 32 32s32-14.3 32-32l0-35.1 17.6 17.5c0 0 0 0 0 0c87.5 87.4 229.3 87.4 316.7 0c24.4-24.4 42.1-53.1 52.9-83.8c5.9-16.7-2.9-34.9-19.5-40.8s-34.9 2.9-40.8 19.5c-7.7 21.8-20.2 42.3-37.8 59.8c-62.5 62.5-163.8 62.5-226.3 0l-.1-.1L125.6 352l34.4 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L48.4 288c-1.6 0-3.2 .1-4.8 .3s-3.1 .5-4.6 1z" />
</svg>
</button>
<div id="hero-er"></div>
<div class="er-fallback" data-i18n="fallback">加载中…</div>
</div>
</div>
</header>
<!-- FEATURES -->
<section id="features">
<div class="container">
<div class="section-head scroll-reveal">
<span class="eyebrow"
><span data-i18n="f_eyebrow">Why this tool</span></span
>
<h2 data-i18n-html="f_title">轻量、<em>优雅</em>,直接能用</h2>
</div>
<div class="features">
<div class="feat scroll-reveal">
<div class="feat-num">01</div>
<div>
<h3 data-i18n="f1_t">Agent Skill 一键安装</h3>
<p data-i18n-html="f1_d">
用 <code>npx skills add ystemsrx/sql_to_er</code> 让 Agent
直接生成与审查 ER 图。
</p>
</div>
</div>
<div class="feat scroll-reveal">
<div class="feat-num">02</div>
<div>
<h3 data-i18n="f2_t">纯前端,打开即用</h3>
<p data-i18n="f2_d">
解析在你的浏览器里完成,SQL 不会被上传到任何地方。
</p>
</div>
</div>
<div class="feat scroll-reveal">
<div class="feat-num">03</div>
<div>
<h3 data-i18n="f3_t">同时支持 SQL 与 DBML</h3>
<p data-i18n="f3_d">
粘贴 CREATE TABLE 或 DBML Ref,自动识别并生成 Chen 模型。
</p>
</div>
</div>
<div class="feat scroll-reveal">
<div class="feat-num">04</div>
<div>
<h3 data-i18n="f4_t">AGPL 开源</h3>
<p data-i18n="f4_d">
代码完全开源,支持导出图片,欢迎 fork、提 issue、发 PR。
</p>
</div>
</div>
</div>
</div>
</section>
<!-- DEMO -->
<section id="demo">
<div class="container">
<div class="section-head scroll-reveal">
<span class="eyebrow"
><span data-i18n="d_eyebrow">Try it out</span></span
>
<h2 data-i18n-html="d_title">两种输入,<em>一种</em>输出</h2>
<p data-i18n="d_sub">
切换标签看看不同格式,点「复制」然后粘到生成器里。
</p>
</div>
<div class="demo-card scroll-reveal">
<div class="demo-bar">
<div class="tab-switch" id="demoTabs" data-active="sql">
<span class="tab-indicator" aria-hidden="true"></span>
<button class="tab is-active" data-tab="sql">SQL</button>
<button class="tab" data-tab="dbml">DBML</button>
</div>
<div class="demo-actions">
<button
class="mini-btn icon-btn"
id="copyBtn"
aria-label="复制"
data-i18n-aria="copy"
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<rect x="9" y="9" width="13" height="13" rx="2" />
<path
d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"
/>
</svg>
</button>
<a
class="mini-btn"
href="sql2er.html"
style="
color: var(--color-accent-warm);
border-color: color-mix(
in srgb,
var(--color-accent-orange) 35%,
transparent
);
"
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<polygon points="5 3 19 12 5 21 5 3" />
</svg>
<span data-i18n="try">打开生成器</span>
</a>
</div>
</div>
<div class="code-panel is-active" data-panel="sql">
<pre><code class="language-sql">CREATE TABLE users (
id INT PRIMARY KEY,
username VARCHAR(255) NOT NULL,
email VARCHAR(255) UNIQUE
);
CREATE TABLE posts (
id INT PRIMARY KEY,
author_id INT,
title VARCHAR(255),
FOREIGN KEY (author_id) REFERENCES users(id)
);</code></pre>
</div>
<div class="code-panel" data-panel="dbml">
<pre><code class="language-dbml">Table users {
id INT [pk]
username VARCHAR(255) [not null]
email VARCHAR(255) [unique]
}
Table posts {
id INT [pk]
author_id INT
title VARCHAR(255)
}
Ref: posts.author_id > users.id</code></pre>
</div>
<div class="demo-foot">
<svg
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
style="color: var(--color-accent-warm); flex-shrink: 0"
>
<circle cx="12" cy="12" r="10" />
<path d="M12 16v-4M12 8h.01" />
</svg>
<span data-i18n="d_hint"
>粘到生成器左侧,点「生成 ER 图」即可。</span
>
</div>
</div>
</div>
</section>
<!-- HOW -->
<section id="how">
<div class="container">
<div class="section-head scroll-reveal">
<span class="eyebrow"
><span data-i18n="h_eyebrow">How it works</span></span
>
<h2 data-i18n-html="h_title">从粘贴到完成,<em>五步</em>以内</h2>
<p data-i18n-html="h_sub">
或者安装 Agent Skill:
<code>npx skills add ystemsrx/sql_to_er</code>
</p>
</div>
<div class="steps scroll-reveal">
<div class="step">
<div class="step-num">i.</div>
<h4 data-i18n="s1_t">打开生成器</h4>
<p data-i18n="s1_d">在线使用,或本地运行 Vite 开发服务器。</p>
</div>
<div class="step">
<div class="step-num">ii.</div>
<h4 data-i18n="s2_t">粘贴代码</h4>
<p data-i18n="s2_d">SQL 或 DBML 都行,编辑器带语法高亮。</p>
</div>
<div class="step">
<div class="step-num">iii.</div>
<h4 data-i18n="s3_t">生成图</h4>
<p data-i18n="s3_d">右侧立刻出现 Chen 模型可视化。</p>
</div>
<div class="step">
<div class="step-num">iv.</div>
<h4 data-i18n="s4_t">手动微调</h4>
<p data-i18n="s4_d">拖节点、双击改名、滚轮缩放。</p>
</div>
<div class="step">
<div class="step-num">v.</div>
<h4 data-i18n="s5_t">智能调整</h4>
<p data-i18n="s5_d">复杂图形一键整理,几秒排整齐。</p>
</div>
</div>
<div class="callout scroll-reveal">
<strong><span data-i18n="warn_t">本地运行提示:</span></strong>
<span data-i18n="warn_d"
>不能直接双击 sql2er.html。请执行
</span>
<code>pnpm dev</code>
<span data-i18n="warn_d2">,再访问 Vite 输出的 /sql2er.html 地址。</span>
</div>
</div>
</section>
<!-- CHEN -->
<section id="chen">
<div class="container">
<div class="section-head scroll-reveal">
<span class="eyebrow"
><span data-i18n="c_eyebrow">Shape semantics</span></span
>
<h2 data-i18n-html="c_title">Chen 模型<em>四件套</em></h2>
</div>
<div class="chen-grid">
<div class="chen-card scroll-reveal">
<div class="chen-shape">
<svg width="88" height="48" viewBox="0 0 88 48">
<rect
x="5"
y="5"
width="78"
height="38"
rx="3"
fill="none"
stroke="currentColor"
stroke-width="1.6"
/>
</svg>
</div>
<h4><em>i.</em> <span data-i18n="c1_t">矩形 · 实体</span></h4>
<p data-i18n="c1_d">对应数据库中的表</p>
</div>
<div class="chen-card scroll-reveal">
<div class="chen-shape">
<svg width="88" height="48" viewBox="0 0 88 48">
<polygon
points="44,4 84,24 44,44 4,24"
fill="none"
stroke="currentColor"
stroke-width="1.6"
/>
</svg>
</div>
<h4><em>ii.</em> <span data-i18n="c2_t">菱形 · 关系</span></h4>
<p data-i18n="c2_d">对应表之间的外键关系</p>
</div>
<div class="chen-card scroll-reveal">
<div class="chen-shape">
<svg width="88" height="48" viewBox="0 0 88 48">
<ellipse
cx="44"
cy="24"
rx="38"
ry="19"
fill="none"
stroke="currentColor"
stroke-width="1.6"
/>
</svg>
</div>
<h4><em>iii.</em> <span data-i18n="c3_t">椭圆 · 属性</span></h4>
<p data-i18n="c3_d">对应表中的列</p>
</div>
<div class="chen-card scroll-reveal">
<div class="chen-shape">
<svg width="88" height="48" viewBox="0 0 88 48">
<ellipse
cx="44"
cy="21"
rx="30"
ry="14"
fill="none"
stroke="currentColor"
stroke-width="1.6"
/>
<text
x="44"
y="25"
text-anchor="middle"
fill="currentColor"
font-size="11"
font-family="serif"
font-style="italic"
text-decoration="underline"
>
id
</text>
<line
x1="34"
y1="42"
x2="54"
y2="42"
stroke="currentColor"
stroke-width="1.6"
/>
</svg>
</div>
<h4><em>iv.</em> <span data-i18n="c4_t">下划线 · 主键</span></h4>
<p data-i18n="c4_d">标识该属性为主键</p>
</div>
</div>
</div>
</section>
<!-- GALLERY(简化:一张图)-->
<section id="gallery">
<div class="container" style="max-width: 860px">
<div class="section-head scroll-reveal">
<span class="eyebrow"
><span data-i18n="g_eyebrow">Showcase</span></span
>
<h2 data-i18n-html="g_title">真实输出<em>长这样</em></h2>
</div>
<figure class="fig scroll-reveal" data-lightbox>
<img
src="./assets/eg1.png"
width="2721"
height="1244"
alt="sql2er 生成的 Chen 模型 ER 图示例:实体矩形、关系菱形与属性椭圆经智能调整后整齐排布"
data-i18n-alt="g_alt"
loading="lazy"
/>
<figcaption>
<span data-i18n="g_cap">一键「智能调整」后的整洁 ER 图</span>
<span class="tag">eg.</span>
</figcaption>
</figure>
</div>
</section>
<!-- FAQ -->
<section id="faq">
<div class="container">
<div
class="section-head scroll-reveal"
style="text-align: center; margin-inline: auto"
>
<span class="eyebrow" style="justify-content: center"
><span>Questions</span></span
>
<h2 data-i18n-html="q_title">你可能想知道的<em>几件事</em></h2>
</div>
<div class="faq">
<details class="scroll-reveal">
<summary data-i18n="q1">数据会上传到服务器吗?</summary>
<div class="faq-wrap">
<div class="faq-body">
<p data-i18n="a1">
不会。工具完全是纯前端的,所有 SQL
解析都在你的浏览器里完成。没有后端、没有日志,你粘贴的代码永远不会离开这个页面。
</p>
</div>
</div>
</details>
<details class="scroll-reveal">
<summary data-i18n="q2">和标准 Chen 模型有什么差别?</summary>
<div class="faq-wrap">
<div class="faq-body">
<p data-i18n="a2">
为了自动化,工具默认用外键字段名作为菱形的标签,用表名 /
列名作为实体 / 属性。学术作业请双击图形改名,或改源 SQL
再重新生成。
</p>
</div>
</div>
</details>
<details class="scroll-reveal">
<summary data-i18n="q3">我双击 sql2er.html 打不开?</summary>
<div class="faq-wrap">
<div class="faq-body">
<p data-i18n-html="a3_html">
源码需要 Vite 编译 TypeScript 并解析前端依赖。请执行
<code>pnpm install && pnpm dev</code>,然后访问 Vite 输出的
<code>/sql2er.html</code> 地址。静态部署请先
<code>pnpm build</code>,再服务 <code>dist/</code>。
</p>
</div>
</div>
</details>
<details class="scroll-reveal">
<summary data-i18n="q4">支持哪些 SQL 方言?</summary>
<div class="faq-wrap">
<div class="faq-body">
<p data-i18n="a4">
解析以 PostgreSQL 方言为主,同时兼容常见的 MySQL / SQLite
CREATE TABLE 语法。外键无论写在列里还是尾部约束里都能识别。
</p>
</div>
</div>
</details>