<?php
require_once __DIR__ . '/includes/config.php';

$currentPage = 'string-length';
$pageTitle = 'String Length Calculator - Count Characters Online | Vivora Tools';
$pageDescription = 'Use this free string length calculator to count characters, words, lines, and characters without spaces instantly. Paste text or upload a .txt file.';
$canonicalPath = 'string-length';
$bodyClass = 'tool-page string-length-page';
$breadcrumbs = [
    ['name' => 'Home', 'url' => ''],
    ['name' => 'String Length Calculator', 'url' => 'string-length'],
];
$structuredData = [
    [
        '@context' => 'https://schema.org',
        '@type' => 'WebApplication',
        'name' => 'String Length Calculator',
        'url' => site_url('string-length'),
        'description' => $pageDescription,
        'applicationCategory' => 'UtilitiesApplication',
        'operatingSystem' => 'Any',
        'offers' => [
            '@type' => 'Offer',
            'price' => '0',
            'priceCurrency' => 'USD',
        ],
        'featureList' => [
            'Instant character counter',
            'Count words and lines',
            'Characters without spaces count',
            'Text file upload',
            'Copy original text',
            'Reset text',
        ],
    ],
    [
        '@context' => 'https://schema.org',
        '@type' => 'FAQPage',
        'mainEntity' => [
            [
                '@type' => 'Question',
                'name' => 'What does the String Length Calculator count?',
                'acceptedAnswer' => [
                    '@type' => 'Answer',
                    'text' => 'It counts every character in the text area, including letters, numbers, symbols, spaces, and line breaks.',
                ],
            ],
            [
                '@type' => 'Question',
                'name' => 'Is this character counter free to use?',
                'acceptedAnswer' => [
                    '@type' => 'Answer',
                    'text' => 'Yes. Vivora Tools provides this string length calculator for free, and you can use it without creating an account.',
                ],
            ],
            [
                '@type' => 'Question',
                'name' => 'Can I upload a text file?',
                'acceptedAnswer' => [
                    '@type' => 'Answer',
                    'text' => 'Yes. Upload a .txt file and the tool will place its contents into the text area and calculate the string length automatically.',
                ],
            ],
            [
                '@type' => 'Question',
                'name' => 'Do you store the text I enter?',
                'acceptedAnswer' => [
                    '@type' => 'Answer',
                    'text' => 'No. The character count runs in your browser, and Vivora Tools does not store the text you type, paste, or upload.',
                ],
            ],
        ],
    ],
];
require __DIR__ . '/includes/head.php';
require __DIR__ . '/includes/header.php';
?>

<section class="tool-hero">
  <div class="container">
    <div class="tool-hero-grid">
      <div>
        <nav class="tool-breadcrumb" aria-label="Breadcrumb">
          <a href="/">Home</a>
          <span>/</span>
          <span>String Length Calculator</span>
        </nav>
        <h1>String Length Calculator</h1>
        <p>
          Count characters online with a fast, free string length calculator. Type, paste, or upload a text file to measure every character instantly, including spaces and line breaks.
        </p>
      </div>
      <div class="tool-result" aria-live="polite">
        <span class="tool-result-label">Length</span>
        <strong id="stringLengthResult">0</strong>
        <span class="tool-result-unit">characters</span>
      </div>
    </div>
  </div>
</section>

<main class="section pt-0">
  <div class="container">
    <section class="string-tool-shell" data-string-length-tool>
      <div class="string-tool-toolbar" aria-label="String length actions">
        <label class="icon-action upload-action" for="stringFileInput" title="Upload .txt file">
          <i class="fa-solid fa-upload" aria-hidden="true"></i>
          <span>Upload .txt</span>
        </label>
        <input id="stringFileInput" class="sr-only" type="file" accept=".txt,text/plain" />
        <button class="icon-action" type="button" id="copyLengthButton" title="Copy text">
          <i class="fa-solid fa-copy" aria-hidden="true"></i>
          <span>Copy</span>
        </button>
        <button class="icon-action danger" type="button" id="resetStringButton" title="Reset text">
          <i class="fa-solid fa-rotate-left" aria-hidden="true"></i>
          <span>Reset</span>
        </button>
      </div>

      <div class="string-tool-layout">
        <div class="string-input-panel">
          <label class="tool-label" for="stringInput">Your text</label>
          <textarea id="stringInput" class="string-textarea" rows="12" placeholder="Paste or type your text here..."></textarea>
          <div class="tool-meta-row">
            <span id="stringToolStatus">Ready to count.</span>
            <span><strong id="wordCountResult">0</strong> words</span>
          </div>
        </div>

        <aside class="string-stats-panel" aria-label="Text statistics">
          <div class="stat-tile primary">
            <span>Characters</span>
            <strong id="stringLengthMirror">0</strong>
          </div>
          <div class="stat-tile">
            <span>Without spaces</span>
            <strong id="stringNoSpacesResult">0</strong>
          </div>
          <div class="stat-tile">
            <span>Lines</span>
            <strong id="lineCountResult">0</strong>
          </div>
          <button class="btn btn-primary calculate-btn" type="button" id="calculateStringButton">
            <i class="fa-solid fa-calculator" aria-hidden="true"></i>
            Calculate String Length
          </button>
        </aside>
      </div>
    </section>

    <section class="tool-content-grid">
      <article>
        <h2>Free online character counter</h2>
        <p>
          This free string length calculator helps you check the exact number of characters in text for forms, social posts, product descriptions, metadata, code snippets, and document limits.
        </p>
      </article>
      <article>
        <h2>What is included?</h2>
        <p>
          The main length includes every character you enter: letters, digits, punctuation, symbols, spaces, tabs, and line breaks.
        </p>
      </article>
    </section>

    <section class="tool-seo-panel" aria-labelledby="stringLengthGuideTitle">
      <div class="tool-seo-intro">
        <span class="tool-seo-kicker">Character counter guide</span>
        <h2 id="stringLengthGuideTitle">How to use the String Length Calculator</h2>
        <p>
          Use this character counter when you need a quick string length check before publishing, submitting a form, writing SEO text, or preparing content with a fixed character limit.
        </p>
      </div>

      <div class="tool-steps">
        <article>
          <span>1</span>
          <h3>Enter your text</h3>
          <p>Paste text into the box, type directly, or upload a plain .txt file from your device.</p>
        </article>
        <article>
          <span>2</span>
          <h3>Check live counts</h3>
          <p>See the total character count, words, lines, and characters without spaces update immediately.</p>
        </article>
        <article>
          <span>3</span>
          <h3>Copy or reset</h3>
          <p>Copy your original text for reuse, or reset the tool when you want to start a new count.</p>
        </article>
      </div>
    </section>

    <section class="tool-seo-panel" aria-labelledby="stringLengthFaqTitle">
      <div class="tool-seo-intro">
        <span class="tool-seo-kicker">FAQs</span>
        <h2 id="stringLengthFaqTitle">String Length Calculator FAQs</h2>
      </div>

      <div class="tool-faq-list">
        <article>
          <h3>What does the String Length Calculator count?</h3>
          <p>It counts every character in the text area, including letters, numbers, symbols, spaces, tabs, and line breaks.</p>
        </article>
        <article>
          <h3>Is this character counter free to use?</h3>
          <p>Yes. Vivora Tools provides this online character counter for free, with no sign-up required.</p>
        </article>
        <article>
          <h3>Can I upload a text file?</h3>
          <p>Yes. Upload a .txt file and the tool will add its contents to the text area and calculate the length automatically.</p>
        </article>
        <article>
          <h3>Do you store the text I enter?</h3>
          <p>No. The counting happens in your browser, and Vivora Tools does not store the text you type, paste, or upload.</p>
        </article>
      </div>
    </section>
  </div>
</main>

<?php require __DIR__ . '/includes/footer.php'; ?>
