By Paul Lukas Reporting by Maggie Overfelt

(FORTUNE Small Business) – Numbers can be magic. Sevens are lucky, of course, and if you add three of them together, you get the special "21," both a classic New York City club and blackjack perfection. Pittsburgh food purveyor Henry John Heinz understood the intrinsic power of numbers when he found himself on an elevated train in New York looking at an advertising placard for a shoe store with "21 styles" in the summer of 1896. He didn't have styles--he had varieties--but he began adding up the assorted pickles, relishes, and other foodstuffs in his product line, thinking he could copy the shoe ad. "Counting up how many products we had," he later recalled, "I counted well beyond 57, but '57' kept coming back in my mind. Seven, seven--there are so many illustrations of the psychological influences of that figure ... that '58 Varieties' or '59 Varieties' did not appeal at all." Heinz immediately got off the train and made arrangements for an ad blitz featuring his inspired idea.

H.J. Heinz was a marketing genius and a branding guru before those cliches even existed. He used those skills--along with a prescient emphasis on purity in food processing--to invent a market for his condiments at a time when people commonly made their own. He also understood that railroads and other technological advancements were creating global markets, and he seized that opportunity to build one of the country's first multinationals. As he wrote in his diary, "Mountains and oceans do not furnish any impassable barrier to the extension of trade.... Our market is the world."

The son of working-class German immigrants, Henry Heinz grew up in western Pennsylvania, where his mother tended a family garden. He loved to garden and he would take the family's surplus vegetables into town to sell to grocers. By age 12, Heinz had his own plot, a horse-drawn cart, and a growing list of customers. In addition to vegetables, he began to sell a grated horseradish product based on his mother's recipe. Most producers sold prepared horseradish in dark jars because, as a business writer of the day noted, "the dealers had adulterated it to so great an extent by adding turnip and wood fibers as filler." To set his horseradish apart and attract those naturally suspicious of food they couldn't see, Heinz bottled his in clear glass and offered samples. "A wide market awaited the manufacturer of food products who set purity and quality above everything else in their preparation," Heinz wrote. In 1861, when he was just 17, Heinz made $2,400 (about $43,000 in today's money).

Eight years later Heinz and his friend Clarence Noble founded Heinz & Noble, selling bottled food products out of Heinz's home. A growing railroad and telegraph system "provided the fast, regular, and dependable transportation and communication so essential to high-volume production and distribution," wrote Alfred D. Chandler Jr. in The Visible Hand: The Managerial Revolution in American Business (1980). Heinz traveled constantly to expand the market for his goods--via train to New York, Cleveland, and other growing cities. He observed gardens becoming scarce in urban areas, so he targeted those regions for his expanding array of prepared goods. Heinz was also an early practitioner of what we would call branding. "He was always looking for ways to build the company's connection to the consumer," says Nancy Koehn, author of Brand New (2001), which examined entrepreneurial branding efforts like Heinz's. At a time most prepared-food products were sold out of anonymous barrels and jugs, Heinz & Noble's products were often individually bottled and labeled with a distinctive anchor logo.

The business would ultimately fail at the end of 1875 because of a credit crunch caused by the economic depression known as the Panic of 1873. Sales had continued to rise, but the company was squeezed by expenses incurred in processing a bumper crop of cucumbers before it could recoup them with sales. Heinz was devastated, both financially and personally. The stress left its mark on him--literally--as Heinz developed boils all over his body. "I am wearing brain and body out," he wrote in a diary entry titled "Panic Times." He also felt ostracized by the negative attention--A TRIO IN A PICKLE read a headline in the Pittsburgh Leader. But within three months he had rallied, scrounging together $3,000 in capital and recruiting his brother and a cousin to front a new food concern, F.&J. Heinz Co. Because of the bankruptcy, Heinz couldn't legally own the company, but he ran the enterprise, and his relatives agreed to sell him a piece of the business after he had paid his debts. He marked that occasion by introducing a new specialty: a tomato-based condiment called ketchup. Eventually it replaced horseradish as the company's signature product.

Heinz's wares had been doing well before his liquidity problems, and the rejuvenated brand picked up where it had left off. By the end of 1876 the business generated $44,474 in revenues (about $665,000 today), and the next five years saw impressive growth as sales exceeded $284,000 in 1881 ($4.7 million today). Heinz took advantage of new technological developments like railroad refrigeration, steam pressure-cooking, and vacuum canning to introduce products like baked beans while increasing the production of others. H.J. also continued to travel extensively, making his first trip to London in 1886, ostensibly on vacation. Impulsively, he popped into the renowned food emporium Fortnum & Mason--purveyors to the royal family--and offered samples to the purchasing manager. "I think, Mr. Heinz, we will take all of them," he said, much to Heinz's surprise. With that successful sale, Heinz made the company one of the first American packaged-food brands to gain a foothold overseas. In 1890 the company hit upon the now familiar combination of the keystone label (so named for the company's home state of Pennsylvania), the neck band, the screw cap, and the octagonal bottle for its ketchup. Marketing the product as a "blessed relief for mother and other women in the household" because of the arduous process required to make ketchup, Heinz had become the largest ketchup producer in the world by the turn of the century. Heinz paid off his debts in 1879 (a year ahead of his goal), and he ultimately bought out his family members in 1888, renaming the business the H.J. Heinz Co.

Heinz's persistent and creative advertising, promotion, and sales tactics fueled product sales. He arranged tastings at every opportunity, from local and state fairs nationwide--most notably at the 1893 World's Fair in Chicago (see box)--to weekly setups in neighborhood grocery stores in which salespeople provided samples to customers while explaining how the products were made. At each site Heinz offered promotional giveaways, like a pickle pin (after the company's most popular item at the time), that would also reinforce an important attribute of the product, such as purity. "We keep our shingle out and then let the public blow our horn, and that counts," wrote Heinz.

"Fifty-Seven Varieties" was H.J. Heinz's most famous promotional idea, and he exploited it with a number of big splashes. In 1899 the Heinz Ocean Pier debuted: It was a proprietary stretch of boardwalk jutting out into the sea in Atlantic City. Crowned by a 70-foot-high "57" sign, it featured a company museum, free samples, and live entertainment. It drew millions of visitors before it was wrecked in a 1944 hurricane. In 1900, Heinz unveiled New York City's first large electric billboard. Six stories high with 1,200 incandescent lights, it promoted the Ocean Pier and boasted of Heinz's "57 Good Things for the Table." Situated at the corner of Fifth Avenue and 23rd Street, it came down in 1902, when the famed Flatiron building was erected on that site.

Despite his status as a clever showman, Heinz was a deeply religious man who believed strongly in his products and, especially, his employees. Having seen the bloody effects of labor strife on Pittsburgh's steel industry, he had resolved from the outset to treat his workers well. His mantra was "Heart power is stronger than horsepower," and he lived up to it by providing a bevy of unusual amenities: Workers got regular breaks and could spend them relaxing in a rooftop garden. "It was a paternalistic, benevolent workplace," said Charles McCollester, director of the Pennsylvania Center for the Study of Labor Relations, who has just completed a study on Heinz. "The women who worked cleaning the cucumbers got weekly manicures. There were singing groups and lectures given at the company." Such benefits earned the "Pickle King" another nickname: the "Prince of Paternalism."

As demand for government oversight of food quality grew around the turn of the century, Heinz stepped up his offensive to differentiate himself from the hordes of unscrupulous producers adding unadvertised preservatives and filler to their products. In 1897, Heinz opened his Pittsburgh facility to the public. "He's the first I've come across that opened up his factory for public tours," says Nancy Koehn, who teaches at the Harvard Business School. "You really build customer trust by saying, literally, 'Come in and see how we make this stuff.'" The tours were an immediate hit and by 1900 were attracting 20,000 visitors annually.

When advocates mobilized in Washington,D.C., to lobby for a law governing food production and labeling, Heinz vocally supported them and dispatched his son Howard there to get President Theodore Roosevelt behind the movement. His motives weren't fully altruistic, of course. Heinz resented being tainted by the dubious tactics of others, and, more important, he understood that if poor quality control brought down processed foods, Heinz would go down with the rest. With regulation, others would have to spend more money to comply and maybe go out of business. In June 1906, the Pure Food and Drug Act became law, outlawing trade in adulterated and misbranded food, drinks, and drugs. Some Heinz competitors, unhappy with the new federal oversight and furious at H.J. for his role in bringing it about, began spreading rumors about Heinz products. There's no such thing as a truly preservative-free ketchup, they whispered: Heinz is using a secret chemical agent. But the company countered by making purity a central theme of its advertising to customers and sellers. "Artificially preserved foods are dangerous to your business as they are to health," warned Heinz ads in The American Grocer in January 1909. Inspectors affirmed the company's claims, and as H.J. had expected, the new regulations ultimately legitimized the industry and set the stage for Heinz's further growth. In 1909, Heinz's sales were $6.13 million. By 1914 they'd almost doubled, to $12 million.

By the time H.J. Heinz died in 1919 at the age of 75, the company's revenue exceeded $20 million and it employed more than 6,500 people. Two Heinz heirs followed in his footsteps. Son Howard steered the company through the Depression, cutting costs and adding important new lines like baby food and ready-to-serve soups. The founder's grandson, H.J. "Jack" Heinz II, succeeded his father in 1941, took the company public in 1946, and oversaw its first acquisitions, including the StarKist and Ore-Ida brands, in the 1960s. But the founder's heirs ran the company much as he had, even though it was now far larger and times had changed. The company was slow to modernize marketing and distribution techniques, clinging to the old ways. Forbes summed up the company's state in a 1964 profile, saying, "Heinz is not doing nearly as well as its competitors in the U.S. and, without the European market, it would be barely getting along." Jack Heinz voluntarily stepped aside as CEO in 1966 (he remained chairman until 1987), and the company moved to professional management. He was the last Heinz to run the company; his son John Heinz III worked there briefly but made his name as an influential Senator.

Meanwhile, "57 Varieties" remains part of the public lexicon, even though it's no longer the official Heinz slogan. It was quietly retired in 1969, the company's centennial year. And with good reason: By that point, Heinz was making more than 1,100 products.