-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext-diff.html
More file actions
305 lines (283 loc) · 28.7 KB
/
text-diff.html
File metadata and controls
305 lines (283 loc) · 28.7 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-CT8E5N460D"></script>
<script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}gtag('js',new Date());gtag('config','G-CT8E5N460D');</script>
<title>Text Diff Checker - Free Online Compare | No Ads</title>
<meta name="description" content="Free online text diff checker to compare two texts and highlight added, removed, and changed content instantly. Great for code reviews, copy edits, and QA workflows. ✅ No ads ✅ No signup ✅ No limits. Runs entirely in your browser.">
<meta name="keywords" content="text diff, text compare online, diff checker, string compare, no ads, no signup, no login, no watermark, free unlimited, browser-based, no installation, local processing">
<meta name="author" content="UseMagicTools">
<meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1">
<meta name="googlebot" content="index, follow">
<meta name="bingbot" content="index, follow">
<meta name="revisit-after" content="7 days">
<meta name="rating" content="general">
<meta name="distribution" content="global">
<meta name="language" content="en">
<link rel="canonical" href="https://www.usemagictools.com/text-diff.html">
<link rel="alternate" hreflang="en" href="https://www.usemagictools.com/text-diff.html">
<link rel="alternate" hreflang="zh-CN" href="https://www.usemagictools.com/text-diff.html">
<link rel="alternate" hreflang="fr" href="https://www.usemagictools.com/text-diff.html">
<link rel="alternate" hreflang="es" href="https://www.usemagictools.com/text-diff.html">
<link rel="alternate" hreflang="x-default" href="https://www.usemagictools.com/text-diff.html">
<meta property="og:type" content="website">
<meta property="og:url" content="https://www.usemagictools.com/text-diff.html">
<meta property="og:title" content="Text Diff Checker - Free Online Compare | No Ads">
<meta property="og:description" content="Compare two texts instantly with highlighted differences. No ads, no signup.">
<meta property="og:image" content="https://www.usemagictools.com/screenshots/text-diff-v1.webp">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:locale" content="en_US">
<meta property="og:locale:alternate" content="zh_CN">
<meta property="og:site_name" content="Magic Toolbox">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@usemagictools">
<meta name="twitter:creator" content="@usemagictools">
<meta name="twitter:title" content="Text Diff Checker - Free Online Compare | No Ads">
<meta name="twitter:description" content="Find text differences with added/removed highlights in browser.">
<meta name="twitter:image" content="https://www.usemagictools.com/screenshots/text-diff-v1.webp">
<script type="application/ld+json">
{
"@context":"https://schema.org",
"@type":"WebApplication",
"name":"Text Diff Checker",
"alternateName":["文本对比","Text Compare","Diff Checker"],
"url":"https://www.usemagictools.com/text-diff.html",
"description":"Free online text diff checker to compare two texts and highlight changes instantly.",
"inLanguage":["en","zh-CN","fr","es"],
"applicationCategory":"UtilitiesApplication",
"operatingSystem":"Web Browser",
"offers":{"@type":"Offer","price":"0","priceCurrency":"USD"},
"author":{"@type":"Person","name":"UseMagicTools"},
"publisher":{"@type":"Organization","name":"Web Toolbox","url":"https://www.usemagictools.com/"},
"featureList":["Line and word level text diff","Ignore case and whitespace options","Color highlight for add/remove","Instant browser comparison","No ads","No signup required","No watermark","100% browser-based","Unlimited usage"],
"screenshot":"https://www.usemagictools.com/screenshots/text-diff-v1.webp"
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://www.usemagictools.com/"
},
{
"@type": "ListItem",
"position": 2,
"name": "Text Diff Checker",
"item": "https://www.usemagictools.com/text-diff.html"
}
]
}
</script>
<script type="application/ld+json">
{
"@context":"https://schema.org",
"@type":"HowTo",
"name":"How to Compare Text Differences",
"totalTime":"PT1M",
"step":[
{"@type":"HowToStep","position":1,"name":"Paste original text","text":"Paste text A in the left input panel."},
{"@type":"HowToStep","position":2,"name":"Paste updated text","text":"Paste text B in the right input panel."},
{"@type":"HowToStep","position":3,"name":"View highlighted diff","text":"Click Compare to see additions and deletions highlighted."}
]
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "Can I compare long text blocks?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Yes. This free text comparison tool handles large text blocks, lengthy code files, and multi-page documents with ease. The diff algorithm efficiently identifies insertions, deletions, and modifications between two text inputs. Results are displayed with clear color-coded highlighting for quick visual review. No signup required, no ads, and all processing happens locally in your browser."
}
},
{
"@type": "Question",
"name": "Can I ignore case differences?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Yes. Enable the ignore-case option before comparing to treat uppercase and lowercase letters as equivalent. This is useful when you want to focus on content differences rather than capitalization variations, especially in code reviews or document comparisons. The case-insensitive mode applies to the entire text. This free browser-based tool requires no signup or server upload."
}
},
{
"@type": "Question",
"name": "Can I ignore spaces and line breaks?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Yes. Enable whitespace normalization to collapse multiple spaces, ignore trailing whitespace, and reduce formatting noise in the comparison results. This helps you focus on meaningful content changes rather than indentation or spacing differences. It is particularly useful for comparing code across different editors. Free, browser-based, no signup needed, and completely private."
}
},
{
"@type": "Question",
"name": "Is this text compare tool private?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Yes. This diff tool runs entirely in your browser using client-side JavaScript — no text content is ever uploaded to any server. Your documents, code, and any sensitive information remain 100% on your local device throughout the comparison process. This makes it safe for comparing confidential contracts, proprietary code, and personal documents. Free with no signup required."
}
},
{
"@type": "Question",
"name": "Is this tool really free with no ads?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Yes, 100% free with no ads, no registration, no watermark, and no usage limits. All processing happens locally in your browser — your data is never uploaded to any server."
}
}
]
}
</script>
<style>
:root { --bg:#020617; --panel:#0b1220; --card:#0f172a; --muted:#94a3b8; --text:#e2e8f0; --border:rgba(148,163,184,.2); --primary:#3b82f6; --primary2:#2563eb; --radius:12px; }
*{box-sizing:border-box;margin:0;padding:0}
body{font-family:"Inter","SF Pro Text",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;background:radial-gradient(circle at 20% 0%,rgba(59,130,246,.18),transparent 40%),radial-gradient(circle at 100% 0%,rgba(16,185,129,.12),transparent 38%),var(--bg);color:var(--text);min-height:100vh;padding:24px 16px 60px}
.container{max-width: 1200px;margin:0 auto}
h1{text-align:center;font-size:2.1rem;letter-spacing:-.02em;margin-bottom:10px}.subtitle{text-align:center;color:var(--muted);margin-bottom:22px}
.card{background:rgba(15,23,42,.82);border:1px solid var(--border);border-radius:var(--radius)}
.tool-card{padding:14px}
.toolbar{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:12px}
.btn{border:1px solid var(--border);background:#0b1220;color:var(--text);padding:8px 12px;border-radius:8px;font-size:13px;cursor:pointer}
.btn:hover{border-color:#64748b}.btn.primary{background:linear-gradient(135deg,var(--primary),var(--primary2));border-color:transparent;color:#fff}
.opts{display:flex;flex-wrap:wrap;gap:16px;margin-bottom:10px;color:var(--muted);font-size:13px}
.layout{display:grid;grid-template-columns:1fr 1fr;gap:12px;min-height:280px}
.panel{border:1px solid var(--border);border-radius:10px;overflow:hidden;display:flex;flex-direction:column;min-height:280px}
.panel-head{padding:10px 12px;border-bottom:1px solid var(--border);font-size:13px;color:var(--muted);background:rgba(2,6,23,.6)}
textarea{width:100%;height:100%;resize:none;border:0;outline:none;padding:14px;background:#020617;color:var(--text);font-size:14px;line-height:1.7;font-family:"JetBrains Mono","SF Mono",Consolas,monospace}
.result{margin-top:12px;border:1px solid var(--border);border-radius:10px;background:#020617;padding:14px;min-height:110px;white-space:pre-wrap;word-break:break-word;font-family:"JetBrains Mono","SF Mono",Consolas,monospace;line-height:1.65}
.add{background:rgba(34,197,94,.25);color:#86efac}.del{background:rgba(239,68,68,.25);color:#fca5a5}.eq{color:#cbd5e1}
.stats{margin-top:10px;color:var(--muted);font-size:13px}.status{margin-top:8px;color:#93c5fd;font-size:13px;min-height:18px}
.features-section,.faq-section,.features-section h2,.faq-section h2,.features-grid,.feature,.related{border:1px solid var(--border);border-radius:10px;padding:12px;background:rgba(2,6,23,.58)}.feature h4,.related h4{margin:8px 0 6px;font-size:14px}.feature p,.related p{color:var(--muted);font-size:13px;line-height:1.55}
.related{text-decoration:none;color:inherit;display:block}.related:hover{border-color:#64748b}
.faq-item{border:1px solid var(--border);border-radius:10px;margin-bottom:8px;overflow:hidden;background:rgba(2,6,23,.5)}.faq-q{width:100%;text-align:left;background:transparent;border:0;color:var(--text);padding:12px 14px;cursor:pointer;font-size:14px}.faq-a{display:none;padding:0 14px 12px;color:var(--muted);font-size:13px;line-height:1.6}.faq-item.active .faq-a{display:block}
@media (max-width:960px){.layout{grid-template-columns:1fr}.features-grid,}
@media (max-width:640px){h1{font-size:1.7rem}.features-grid,}
</style>
<link rel="stylesheet" href="common/common.css">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="icon" href="/favicon.ico" sizes="48x48">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
</head>
<body>
<div class="container">
<h1 data-i18n="title">Text Diff Checker</h1>
<p class="subtitle" data-i18n="subtitle">Compare two texts and highlight additions, deletions, and edits</p>
<section class="card tool-card">
<div class="toolbar"><button class="btn" id="sampleBtn" data-i18n="sample">Insert Sample</button><button class="btn" id="clearBtn" data-i18n="clear">Clear</button><button class="btn primary" id="compareBtn" data-i18n="compare">Compare Text</button><button class="btn" id="copyBtn" data-i18n="copy">Copy Result</button></div>
<div class="opts">
<label><input type="checkbox" id="ignoreCase"> <span data-i18n="ignoreCase">Ignore case</span></label>
<label><input type="checkbox" id="ignoreSpace"> <span data-i18n="ignoreSpace">Ignore extra spaces</span></label>
</div>
<div class="layout">
<div class="panel"><div class="panel-head" data-i18n="leftPanel">Original Text</div><textarea id="leftInput" data-i18n-placeholder="leftPlaceholder" placeholder="Paste original text..."></textarea></div>
<div class="panel"><div class="panel-head" data-i18n="rightPanel">Updated Text</div><textarea id="rightInput" data-i18n-placeholder="rightPlaceholder" placeholder="Paste updated text..."></textarea></div>
</div>
<div class="result" id="result"></div>
<div class="stats" id="stats"></div>
<div class="status" id="status"></div>
</section>
<div class="trust-bar"><span class="trust-item" data-i18n="trust_users">🌍 Used by 50,000+ users</span><span class="trust-item" data-i18n="trust_rating">⭐ 4.9/5 rating</span><span class="trust-item" data-i18n="trust_privacy">🔒 100% Private</span><span class="trust-item" data-i18n="trust_free">🚫 No Ads, No Signup</span></div>
<section class="features-section">
<h2 data-i18n="features_title">Text Compare Features</h2>
<div class="features-grid">
<article class="feature"><div>🔒</div><h4 data-i18n="f1_t">100% Free & Private</h4><p data-i18n="f1_d">No ads, no signup, no watermark. Everything runs locally in your browser. Your data never leaves your device.</p></article>
<article class="feature"><div>⚡</div><h4 data-i18n="f2_t">Instant Diff</h4><p data-i18n="f2_d">Compare text instantly and highlight added or removed content.</p></article>
<article class="feature"><div>🧹</div><h4 data-i18n="f3_t">Noise Filters</h4><p data-i18n="f3_d">Ignore case and spacing differences to focus on real content changes.</p></article>
<article class="feature"><div>📋</div><h4 data-i18n="f4_t">Copy Result</h4><p data-i18n="f4_d">Copy comparison result quickly for QA and review workflows.</p></article>
</div>
</section>
<section class="faq-section">
<h2 data-i18n="faq_title">Frequently Asked Questions</h2>
<div class="faq-item"><button class="faq-q" data-i18n="faq1_q">Can I compare code snippets?</button><div class="faq-a" data-i18n="faq1_a">Yes. This tool works for plain text, code snippets, and documentation.</div></div>
<div class="faq-item"><button class="faq-q" data-i18n="faq2_q">How are changes highlighted?</button><div class="faq-a" data-i18n="faq2_a">Added text is highlighted in green and removed text in red.</div></div>
<div class="faq-item"><button class="faq-q" data-i18n="faq3_q">Can I ignore formatting differences?</button><div class="faq-a" data-i18n="faq3_a">Yes. Enable ignore-case and whitespace normalization options.</div></div>
<div class="faq-item"><button class="faq-q" data-i18n="faq4_q">Is my content stored anywhere?</button><div class="faq-a" data-i18n="faq4_a">No. Everything stays in your browser and is never uploaded.</div></div>
<div class="faq-item"><button class="faq-q" data-i18n="faq_free_q">Is this tool really free with no ads?</button><div class="faq-a" data-i18n="faq_free_a">Yes, 100% free with no ads, no registration, no watermark, and no usage limits. All processing happens locally in your browser — your data is never uploaded to any server.</div></div>
</section>
<section class="related-tools">
<h3 data-i18n="related_title">Related Tools</h3>
<div class="related-grid">
<a class="related" href="markdown-editor.html"><div>📝</div><h4 data-i18n="r1_t">Markdown Editor</h4><p data-i18n="r1_d">Write markdown with instant rendered preview.</p></a>
<a class="related" href="csv-json.html"><div>🔄</div><h4 data-i18n="r2_t">CSV JSON Converter</h4><p data-i18n="r2_d">Convert structured text formats for development.</p></a>
<a class="related" href="regex-tester.html"><div>🧪</div><h4 data-i18n="r3_t">Regex Tester</h4><p data-i18n="r3_d">Test and debug regular expressions online.</p></a>
<a class="related" href="cron-generator.html"><div>⏰</div><h4 data-i18n="r4_t">Cron Generator</h4><p data-i18n="r4_d">Generate cron schedules with readable descriptions.</p></a>
</div>
</section>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/diff_match_patch/20121119/diff_match_patch.js"></script>
<script>
(function() {
'use strict';
var i18n = {
en:{tool_name:'Text Diff Checker',title:'Text Diff Checker',subtitle:'Compare two texts and highlight additions, deletions, and edits',sample:'Insert Sample',clear:'Clear',compare:'Compare Text',copy:'Copy Result',ignoreCase:'Ignore case',ignoreSpace:'Ignore extra spaces',leftPanel:'Original Text',rightPanel:'Updated Text',leftPlaceholder:'Paste original text...',rightPlaceholder:'Paste updated text...',stats:'Added: {a} · Removed: {d} · Unchanged: {e}',copied:'Copied to clipboard',trust_users:'🌍 Used by 50,000+ users',trust_rating:'⭐ 4.9/5 rating',trust_privacy:'🔒 100% Private',trust_free:'🚫 No Ads, No Signup',features_title:'Text Compare Features',f1_t:'100% Free & Private',f1_d:'No ads, no signup, no watermark. Everything runs locally in your browser. Your data never leaves your device.',f2_t:'Instant Diff',f2_d:'Compare text instantly and highlight added or removed content.',f3_t:'Noise Filters',f3_d:'Ignore case and spacing differences to focus on real content changes.',f4_t:'Copy Result',f4_d:'Copy comparison result quickly for QA and review workflows.',faq_title:'Frequently Asked Questions',faq1_q:'Can I compare code snippets?',faq1_a:'Yes. This tool works for plain text, code snippets, and documentation.',faq2_q:'How are changes highlighted?',faq2_a:'Added text is highlighted in green and removed text in red.',faq3_q:'Can I ignore formatting differences?',faq3_a:'Yes. Enable ignore-case and whitespace normalization options.',faq4_q:'Is my content stored anywhere?',faq4_a:'No. Everything stays in your browser and is never uploaded.',faq_free_q:'Is this tool really free with no ads?',faq_free_a:'Yes, 100% free with no ads, no registration, no watermark, and no usage limits. All processing happens locally in your browser — your data is never uploaded to any server.',relatedToolsTitle:'Related Tools',relatedTool1:'Markdown Editor',relatedTool1Desc:'Write markdown with instant rendered preview.',relatedTool2:'CSV JSON Converter',relatedTool2Desc:'Convert structured text formats for development.',relatedTool3:'Regex Tester',relatedTool3Desc:'Test and debug regular expressions online.',relatedTool4:'Cron Generator',relatedTool4Desc:'Generate cron schedules with readable descriptions.'},
'zh-CN':{tool_name:'文本对比工具',title:'文本对比工具',subtitle:'比较两段文本,突出新增、删除和修改内容',sample:'插入示例',clear:'清空',compare:'开始比较',copy:'复制结果',ignoreCase:'忽略大小写',ignoreSpace:'忽略多余空格',leftPanel:'原始文本',rightPanel:'新文本',leftPlaceholder:'粘贴原始文本...',rightPlaceholder:'粘贴新文本...',stats:'新增:{a} · 删除:{d} · 相同:{e}',copied:'已复制到剪贴板',trust_users:'🌍 超过 50,000 用户使用',trust_rating:'⭐ 4.9/5 好评',trust_privacy:'🔒 100% 隐私安全',trust_free:'🚫 无广告、无需注册',features_title:'文本比较功能',f1_t:'100% 免费且安全',f1_d:'无广告、无需注册、无水印。所有处理都在浏览器本地完成,数据不会上传到任何服务器。',f2_t:'即时差异高亮',f2_d:'输入后立即对比,快速识别新增和删除内容。',f3_t:'降噪过滤',f3_d:'可忽略大小写和空白差异,聚焦核心变更。',f4_t:'结果一键复制',f4_d:'便于 QA、评审和文档审校场景复用。',faq_title:'常见问题',faq1_q:'可以比较代码片段吗?',faq1_a:'可以,支持普通文本、代码和文档内容比较。',faq2_q:'差异如何显示?',faq2_a:'新增内容绿色标记,删除内容红色标记。',faq3_q:'可以忽略格式差异吗?',faq3_a:'可以,开启忽略大小写和空白选项即可。',faq4_q:'内容会被保存吗?',faq4_a:'不会,全部在浏览器本地处理。',faq_free_q:'这个工具真的免费且无广告吗?',faq_free_a:'是的,100% 免费,无广告、无需注册、无水印、无限制。所有处理都在浏览器本地完成,你的数据不会上传到任何服务器。',relatedToolsTitle:'相关工具',relatedTool1:'Markdown 编辑器',relatedTool1Desc:'编写 Markdown 并实时预览。',relatedTool2:'CSV JSON 转换',relatedTool2Desc:'开发常用结构化文本互转工具。',relatedTool3:'正则测试器',relatedTool3Desc:'在线调试和验证正则表达式。',relatedTool4:'Cron 生成器',relatedTool4Desc:'生成定时表达式并查看含义。'},
fr:{tool_name:'Comparateur de texte',title:'Comparateur de texte',subtitle:'Comparez deux textes et surlignez les ajouts et suppressions',sample:'Insérer un exemple',clear:'Effacer',compare:'Comparer',copy:'Copier le résultat',ignoreCase:'Ignorer la casse',ignoreSpace:'Ignorer les espaces en trop',leftPanel:'Texte original',rightPanel:'Texte modifié',leftPlaceholder:'Collez le texte original...',rightPlaceholder:'Collez le texte modifié...',stats:'Ajouté: {a} · Supprimé: {d} · Identique: {e}',copied:'Copié dans le presse-papiers',trust_users:'🌍 Utilisé par 50 000+ utilisateurs',trust_rating:'⭐ Note 4.9/5',trust_privacy:'🔒 100% Privé',trust_free:'🚫 Sans pub, sans inscription',features_title:'Fonctions de comparaison',f1_t:'100% Gratuit et Privé',f1_d:'Sans publicité, sans inscription, sans filigrane. Tout est traité localement dans votre navigateur.',f2_t:'Diff instantané',f2_d:'Comparez instantanément et surlignez les changements.',f3_t:'Filtres anti-bruit',f3_d:'Ignorez casse et espaces pour se concentrer sur le fond.',f4_t:'Copie rapide',f4_d:'Copiez le résultat pour QA et revue de contenu.',faq_title:'Questions fréquentes',faq1_q:'Puis-je comparer du code ?',faq1_a:'Oui, l outil fonctionne pour texte, code et documentation.',faq2_q:'Comment les changements sont-ils affichés ?',faq2_a:'Les ajouts sont en vert et les suppressions en rouge.',faq3_q:'Puis-je ignorer les différences de format ?',faq3_a:'Oui, activez les options de normalisation.',faq4_q:'Mes données sont-elles stockées ?',faq4_a:'Non, tout reste dans le navigateur.',faq_free_q:'Cet outil est-il vraiment gratuit et sans pub ?',faq_free_a:'Oui, 100% gratuit, sans publicité, sans inscription, sans filigrane et sans limites. Tout est traité localement dans votre navigateur — vos données ne sont jamais téléversées.',relatedToolsTitle:'Outils associés',relatedTool1:'Éditeur Markdown',relatedTool1Desc:'Rédiger du markdown avec aperçu instantané.',relatedTool2:'Convertisseur CSV JSON',relatedTool2Desc:'Convertir des formats structurés pour le dev.',relatedTool3:'Testeur Regex',relatedTool3Desc:'Tester les expressions régulières en ligne.',relatedTool4:'Générateur Cron',relatedTool4Desc:'Créer des expressions cron lisibles.'},
es:{tool_name:'Comparador de texto',title:'Comparador de texto',subtitle:'Compara dos textos y resalta adiciones, eliminaciones y cambios',sample:'Insertar ejemplo',clear:'Limpiar',compare:'Comparar texto',copy:'Copiar resultado',ignoreCase:'Ignorar mayúsculas',ignoreSpace:'Ignorar espacios extra',leftPanel:'Texto original',rightPanel:'Texto actualizado',leftPlaceholder:'Pega el texto original...',rightPlaceholder:'Pega el texto actualizado...',stats:'Añadido: {a} · Eliminado: {d} · Igual: {e}',copied:'Copiado al portapapeles',trust_users:'🌍 Usado por más de 50,000 usuarios',trust_rating:'⭐ Calificación 4.9/5',trust_privacy:'🔒 100% Privado',trust_free:'🚫 Sin anuncios, sin registro',features_title:'Funciones de comparación',f1_t:'100% Gratis y Privado',f1_d:'Sin anuncios, sin registro, sin marca de agua. Todo se procesa localmente en tu navegador.',f2_t:'Diff instantáneo',f2_d:'Compara al instante y detecta adiciones y eliminaciones.',f3_t:'Filtros de ruido',f3_d:'Ignora diferencias de formato para revisar contenido real.',f4_t:'Copiar resultado',f4_d:'Copia rápidamente la salida para QA y revisión.',faq_title:'Preguntas frecuentes',faq1_q:'¿Puedo comparar código?',faq1_a:'Sí, funciona con texto, código y documentos.',faq2_q:'¿Cómo se muestran los cambios?',faq2_a:'Lo añadido se marca en verde y lo eliminado en rojo.',faq3_q:'¿Puedo ignorar formato?',faq3_a:'Sí, activa opciones para ignorar mayúsculas y espacios.',faq4_q:'¿Se guardan mis datos?',faq4_a:'No, todo queda en el navegador.',faq_free_q:'¿Esta herramienta es realmente gratis y sin anuncios?',faq_free_a:'Sí, 100% gratis, sin anuncios, sin registro, sin marca de agua y sin límites. Todo el procesamiento ocurre localmente en tu navegador: tus datos nunca se suben a ningún servidor.',relatedToolsTitle:'Herramientas relacionadas',relatedTool1:'Editor Markdown',relatedTool1Desc:'Escribe markdown con vista previa al instante.',relatedTool2:'Convertidor CSV JSON',relatedTool2Desc:'Convierte formatos estructurados para desarrollo.',relatedTool3:'Probador Regex',relatedTool3Desc:'Prueba expresiones regulares en línea.',relatedTool4:'Generador Cron',relatedTool4Desc:'Crea cron y lee su descripción.'}
};
var dmp = new diff_match_patch();
var leftInput = document.getElementById('leftInput');
var rightInput = document.getElementById('rightInput');
var result = document.getElementById('result');
var stats = document.getElementById('stats');
var statusEl = document.getElementById('status');
function getLang() {
return localStorage.getItem('toolbox_lang') || 'en';
}
function t(key){
var lang = getLang();
var d=i18n[lang]||i18n.en;
return d[key]||i18n.en[key]||key;
}
function normalize(text){
var out=text;
if(document.getElementById('ignoreCase').checked) out=out.toLowerCase();
if(document.getElementById('ignoreSpace').checked) out=out.replace(/\s+/g,' ').trim();
return out;
}
function compare(){
var a = leftInput.value || '';
var b = rightInput.value || '';
var ta = normalize(a);
var tb = normalize(b);
var diffs = dmp.diff_main(ta,tb);
dmp.diff_cleanupSemantic(diffs);
var html = '';
var add=0, del=0, eq=0;
diffs.forEach(function(part){
var text = part[1]
.replace(/&/g,'&')
.replace(/</g,'<')
.replace(/>/g,'>')
.replace(/\n/g,'<br>');
if(part[0]===1){html += '<span class="add">'+text+'</span>'; add += part[1].length;}
else if(part[0]===-1){html += '<span class="del">'+text+'</span>'; del += part[1].length;}
else {html += '<span class="eq">'+text+'</span>'; eq += part[1].length;}
});
result.innerHTML = html || '<span class="eq">(empty)</span>';
stats.textContent = t('stats').replace('{a}',String(add)).replace('{d}',String(del)).replace('{e}',String(eq));
}
function setStatus(v){statusEl.textContent=v||''}
document.getElementById('compareBtn').addEventListener('click', compare);
document.getElementById('clearBtn').addEventListener('click', function(){leftInput.value='';rightInput.value='';result.textContent='';stats.textContent='';setStatus('');});
document.getElementById('sampleBtn').addEventListener('click', function(){leftInput.value='Hello World\nVersion 1\nLine 3';rightInput.value='Hello, World!\nVersion 2\nLine 3\nNew line';compare();});
document.getElementById('copyBtn').addEventListener('click', function(){navigator.clipboard.writeText(result.innerText || '').then(function(){setStatus(t('copied'));});});
document.querySelectorAll('.faq-q').forEach(function(btn){btn.addEventListener('click', function(){var item=btn.parentElement;var open=item.classList.contains('active');document.querySelectorAll('.faq-item').forEach(function(it){it.classList.remove('active')});if(!open)item.classList.add('active');});});
compare();
window._translations = i18n;
})();
</script>
<script src="common/common.js" data-tool-id="text-diff" data-tool-name="Text Diff Checker" data-category="text"></script>
<script>WebToolbox.init(window._translations);</script>
</body>
</html>