
<PAGE>
                                                                     EXHIBIT 5.1
 
February 23, 1998
 
Hewlett-Packard Company
3000 Hanover Street
Palo Alto, CA 94304
 
Ladies and Gentlemen:
 
    I have examined the Registration Statement on Form S-4 (the "Registration
Statement") to be filed by Hewlett-Packard Company ("HP") with the Securities
and Exchange Commission on or about February 24, 1998 in connection with the
registration under the Securities Act of 1933, as amended, of shares (the
"Shares") of HP's Common Stock, par value $1.00 per share, to be issued in
connection with the merger of Whistler Acquisition Corporation, a wholly-owned
Delaware subsidiary of HP, with and into Heartstream, Inc. I have examined the
proceedings taken and am familiar with the proceedings proposed to be taken by
HP in connection with the sale and issuance of the Shares.
 
    It is my opinion that the Shares, when issued and sold in the manner
described in the Registration Statement, will be legally and validly issued,
fully paid and nonassessable.
 
    I consent to the use of this opinion as an exhibit to said Registration
Statement and further consent to the use of my name wherever appearing in said
Registration Statement and any amendments thereto.
 
                                          Very truly yours,
 
                                          /s/ D. Craig Nordlund
                                          --------------------------------------
                                          D. Craig Nordlund
                                          Associate General Counsel and
                                          Secretary
