النص
CRLF ↔ LF Converter
تحويل نهايات الأسطر بين Windows (CRLF) وUnix/macOS (LF) وMac الكلاسيكي (CR)، مع اكتشاف النهايات المختلطة.
يقوم المتصفح بتطبيع النص الملصق في الحقل إلى LF تلقائيًا، لذا يتعذر هنا اكتشاف CRLF/CR الأصلية — لتحليل أو تحويل ملف يحتوي على CRLF/CR حقيقية، استخدم رفع الملف أعلاه.
Windows, Unix/macOS, and the old classic Mac historically use different characters to mark the end of a line — CRLF, LF, and CR respectively. Mixing these styles in one file often causes odd artifacts in diffs or editors. This tool converts line endings to one style and detects mixed ones.
How to use it
- Paste text and the tool automatically detects the current line-ending style, including a mixed one.
- Pick a target format (CRLF, LF, or CR) and the conversion happens instantly.
- If several styles are found in the same file, that's flagged with a separate warning.
Common uses
- Fixing a file where git diff shows every line as changed because of differing line endings, even though the content itself didn't actually change.
- Converting a text file to the format a specific system or script expects (a Unix script, for instance, expects LF).
- Debugging why a file opened in a Windows editor shows the entire text on one line (a sign of plain LF with no CR).
Things to keep in mind
Git can automate this conversion itself through core.autocrlf or .gitattributes — often more convenient than converting files in a repository by hand.
Mixed line endings in one file aren't always visible at a glance, but they can break parsers or scripts that expect one specific style.
مقالة عن هذه الأداة: CRLF وLF: لماذا لا تزال نهايات الأسطر تسبّب مشاكل
الأسئلة الشائعة
لماذا تختلف نهايات الأسطر بين أنظمة التشغيل؟
أنظمة Windows تستخدم تقليديًا CRLF (\r\n) لنهاية كل سطر، بينما تستخدم Unix وmacOS الحديث LF (\n) فقط، أما أجهزة Mac القديمة فكانت تستخدم CR (\r) وحده؛ وهذا الاختلاف مهم عند استخدام Git أو تشغيل سكربتات shell أو تبادل الملفات بين أنظمة مختلفة.
لماذا لا تظهر لي CRLF أو CR حقيقية عند لصق النص في الحقل؟
المتصفح يطبّع أي نص يُلصَق في حقل نصي إلى LF تلقائيًا، لذا يستحيل اكتشاف نهايات CRLF أو CR الأصلية من نص مُلصَق؛ لتحليل أو تحويل نهايات الأسطر الحقيقية في ملف يجب رفعه مباشرة عبر خيار رفع الملف.
هل الملف الذي أرفعه يُرسل إلى خادم؟
لا، قراءة الملف وتحليل نهايات الأسطر وتحويلها تتم بالكامل داخل متصفحك عبر JavaScript، دون رفع الملف إلى أي خادم.
ماذا أفعل إذا كان الملف يحتوي على مزيج من CRLF وLF؟
قد يحتوي الملف الذي حُرِّر في عدة محررات أو على أنظمة تشغيل مختلفة على النمطين معًا. يجب تطبيق التحويل على الملف بأكمله، لا فقط على الأسطر التي تبدو "مشبوهة" — وإلا ستبقى بعض النهايات المشكِلة دون ملاحظة.
هل يمكن أتمتة التحويل عبر git؟
نعم، يقوم إعداد core.autocrlf في git بتحويل نهايات الأسطر تلقائيًا عند السحب والإيداع، بينما يتيح ملف .gitattributes تحديد نمط النهايات صراحة لأنواع ملفات معينة في المستودع.